CodeIgniter在万网 iis7 rewrite 不起作用的解决办法
本帖最后由 iserich 于 2015-7-2 16:51 编辑收到配置信息的时候,都设置好了。网站上传之后发现,rewrite不起作用。
调查后发现,客户的主机类型是windows,web服务器是IIS
由于机制的不同,Apache 使用 .htaccess 来设置伪静态
IIS是使用web.config 来设置伪静态
解决办法:通过配置好的IIS导入规则,从.htaccess 转换到web.config 格式
.htaacess文件:
<IfModule mod_rewrite.c> RewriteEngine On# RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 </IfModule>
web.config文件:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="已导入的规则 1" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
有用,!
谢谢了!!!
<rewrite>
<rules>
<rule name="CI框架 UrlReWrite" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="bp/index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
放在<system.webServer>这里</system.webServer> 注意使用utf8格式保存web.config
页:
[1]