天天看点

IIS 伪静态设置

1、将下载的 iis rewrite 组件解压,放到适当的目录(如 c:rewrite)下。

IIS 伪静态设置

2、在“iis管理器”里选择网站,右键,属性。

IIS 伪静态设置

3、选择“isapi”,点击“添加”。

IIS 伪静态设置

4、填入筛选器名称,如“rewrite”。

IIS 伪静态设置

5、可执行文件下方点击“浏览”,选择刚才解压的rewrite组件位置,rewrite.dll。

IIS 伪静态设置

6、确认选择正确后,点击“确定”。

IIS 伪静态设置

7、点击“确定”,完成筛选器添加。

IIS 伪静态设置

8、重启iis。

IIS 伪静态设置

9、重启iis后,再次选择站点,右键,属性,看到如下所示向上的绿箭头,说明 iis rewrite 成功添加并运行。

IIS 伪静态设置

iis rewrite 规则设置

解压后的 iis rewrite 组件目录(如 c:rewrite)中,有一个 httpd.ini 文件,将相应规则写入到这个文件中即可。

1. 安装重写插件rewrite.dll

如果你的 iis 服务器加载过 rewrite.dll 则可以不用下载。

2. 配置 httpd.ini

打开你的httpd.ini,找到

IIS 伪静态设置

[isapi_rewrite]  

# 3600 = 1 hour  

cacheclockrate 3600  

repeatlimit 32  

# protect httpd.ini and httpd.parse.errors files  

# from accessing through http  

rewriterule ^(.*)/archiver/([a-z0-9-]+.html)$ $1/archiver/index.php?$2  

rewriterule ^(.*)/forum-([0-9]+)-([0-9]+).html$ $1/forumdisplay.php?fid=$2&page=$3  

rewriterule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/viewthread.php?tid=$2&extra=page%3d$4&page=$3  

rewriterule ^(.*)/profile-(username|uid)-(.+?).html$ $1/viewpro.php?$2=$3  

以上是 discuz!官方提供的配置代码,注意正则格式。

3. 应用

比如,将read.php?bl_id=123&bu_id=456 伪静态成 /html/123/456.html

可以这样写:

IIS 伪静态设置

rewriterule ^(.*)/html/([0-9]+)/([0-9]+).html$ $1/read.php?bl_id=$2&bu_id=$3  

pw的规则:[isapi_rewrite]

IIS 伪静态设置

rewriterule ^(.*)-htm-(.*)$ $1.php?$2  

rewriterule ^(.*)/simple/([a-z0-9_]+.html)$ $1/simple/index.php?$2