Need a web.config file instead of .htaccess for co

2020-02-16 03:31发布

I still not able to get the web.config file working no matter how I try it still does not redirect to other pages. I am using codeigniter and hosting the application in IIS platform here is my .htaccess file, please can anyone convert this code to 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>

1条回答
相关推荐>>
2楼-- · 2020-02-16 04:24

Your web.config file should look something like this:

<?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 is not used in web.config files as is, so you may need to change the URL paths accordingly.

查看更多
登录 后发表回答