我尝试在IIS上使用codeigniter,我能够配置php在IIS上工作,但当我尝试将.htaccess更改为web.config时,它给了我错误
我的htaccess代码是
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
和我的web.config代码:
<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>
我仍然可以看到这个屏幕
答案 0 :(得分:0)
Codeigniter拥有自己的路由类,这将使您的生活更加简单,特别是如果有可能在服务器操作系统之间切换。
以下web.config文件是使CI与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>
然后在 application / config / routes.php 中,示例行将是
$route['page/(change_lang)/(.*)'] = 'page/$1/$2';
希望这有帮助!