无论我如何尝试,我仍然无法使web.config文件正常工作仍然无法重定向到其他页面。我在使用codeigniter并在IIS平台上托管应用程序这里是我的.htaccess文件,请将此代码转换为web.config吗?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /travel/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
答案 0 :(得分:1)
您的web.config文件应如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Index">
<match url="^(.*)$"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php/{R:1}"/>
</rule>
</rules>
</rewrite>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/somedir/oops404.htm" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
RewriteBase未按原样用于web.config文件,因此您可能需要相应地更改URL路径。