IIS7配置YII2的url重写规则

安装个yii2.0.9玩玩,网上一搜索竟然没有iis的配置方法,见鬼了难道没人用iis了,只能靠自己摸索了,首先要安装我之前写的:IIS7.5伪静态URL_rewrite模块,接着再yii2对应的项目web目录下创建web.config,把一下内容复制进去即可,配置分享如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
 <rewrite>
 <rules>
                <rule name="YII2">
                    <match url=".*" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?r={R:0}" />
                </rule>
  
 </rules>
</rewrite>
   </system.webServer>  
</configuration>
 </system.webServer>
 </configuration>
此条目发表在开源代码分类目录,贴了标签。将固定链接加入收藏夹。

发表回复