问题
I trying to use codeigniter on IIS, I was able to config php to work on IIS but when I tried to change the .htaccess to web.config it gives me error
my htaccess code is
RewriteEngine on
Options +FollowSymLinks
RewriteRule ^admin(.*) index.php/admin$1
RewriteRule ^supervisor/([0-9]+)(.*) index.php/supervisor_$1/$2
RewriteRule ^moder/(.*)/([0-9]+)(.*) index.php/moder/$1/$2
rewriteRule ^(login|logoff)(.*) index.php/base/$1$2
RewriteRule ^(attachment|meeting|thread|attachments|profile|search|roles|cat)(.*) index.php/moder/$1$2
RewriteRule ^(about|contact|new_majlis|sk|supervideo|superandsk|guest)(.*) index.php/page/$1$2
RewriteRule ^(2.2-release-notes)(.*) index.php/page/release_notes
RewriteRule ^page/(change_lang)/(.*) index.php/page/$1/$2
and for my web.config code :
<rewrite>
<rules>
<rule name="rule 1m">
<match url="^admin(.*)" />
<action type="Rewrite" url="/index.php/admin{R:1}" />
</rule>
<rule name="rule 2m">
<match url="^supervisor/([0-9]+)(.*)" />
<action type="Rewrite" url="/index.php/supervisor_{R:1}/{R:2}" />
</rule>
<rule name="rule 3m">
<match url="^moder/(.*)/([0-9]+)(.*)" />
<action type="Rewrite" url="/index.php/moder/{R:1}/{R:2}" />
</rule>
<rule name="rule 4m">
<match url="^(login|logoff)(.*)" />
<action type="Rewrite" url="/index.php/base/{R:1}{R:2}" />
</rule>
<rule name="rule 5m">
<match url="^(attachment|meeting|thread|attachments|profile|search|roles|cat)(.*)" />
<action type="Rewrite" url="/index.php/moder/{R:1}{R:2}" />
</rule>
<rule name="rule 6m">
<match url="^(about|contact|new_majlis|sk|supervideo|superandsk|guest)(.*)" />
<action type="Rewrite" url="/index.php/page/{R:1}{R:2}" />
</rule>
<rule name="rule 7m">
<match url="^(2.2-release-notes)(.*)" />
<action type="Rewrite" url="/index.php/page/release_notes" />
</rule>
<rule name="rule 8m">
<match url="^page/(change_lang)/(.*)" />
<action type="Rewrite" url="/index.php/page/{R:1}/{R:2}" />
</rule>
</rules>
</rewrite>
i still get this screen
回答1:
Codeigniter has it's own routing class which will make you're life much more simple especially if there is possibility of switching between Server OS's.
The following web.config file is the bare basics of getting CI to work with IIS:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to index.php">
<match url="index.php|robots.txt|images|test.php" />
<action type="None" />
</rule>
<rule name="Rewrite CI Index">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html|ttf|woff" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Then in application/config/routes.php an example line would be
$route['page/(change_lang)/(.*)'] = 'page/$1/$2';
Hope this helps!
来源:https://stackoverflow.com/questions/27294427/change-codeigniter-htaccess-to-web-config-error