用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2789|回复: 3
收起左侧

[服务器] CodeIgniter在万网 iis7 rewrite 不起作用的解决办法

[复制链接]
发表于 2015-7-2 16:50:30 | 显示全部楼层 |阅读模式
本帖最后由 iserich 于 2015-7-2 16:51 编辑

        收到配置信息的时候,都设置好了。网站上传之后发现,rewrite不起作用。

        调查后发现,客户的主机类型是windows,web服务器是IIS

        由于机制的不同,Apache 使用 .htaccess 来设置伪静态
        IIS是使用web.config 来设置伪静态

        解决办法:通过配置好的IIS导入规则,从.htaccess 转换到web.config 格式
.htaacess文件:



  1. <IfModule mod_rewrite.c>    RewriteEngine On#    RewriteBase /    RewriteCond %{REQUEST_FILENAME} !-f    RewriteCond %{REQUEST_FILENAME} !-d    RewriteRule ^(.*)$ index.php/$1 [L]</IfModule>
复制代码


web.config文件:
XML复制代码
<?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>
复制代码


发表于 2015-7-13 09:34:34 | 显示全部楼层
有用,!
谢谢了!!!
发表于 2016-6-29 10:11:20 | 显示全部楼层
XML复制代码
 
        <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>
发表于 2016-6-29 10:11:49 | 显示全部楼层
注意使用utf8格式保存web.config

本版积分规则