龙哥 发表于 2015-11-4 10:47

Windows服务器下IIS设置伪静态方法

以Windows2003为例
1、将下载的IIS Rewrite 组件解压,放到适当的目录(如 C:Rewrite)下,IIS Rewrite 组件下载 http://www.helicontech.com/download-isapi_rewrite.htm , IIS Rewrite 简化版组件下载 http://www.newhua.com/soft/71446.htm ,下载下来解压后不用安装拷到目
1、将下载的IIS Rewrite 组件解压,放到适当的目录(如 C:Rewrite)下,IIS Rewrite 组件下载http://www.helicontech.com/download-isapi_rewrite.htm,IIS Rewrite 简化版组件下载http://www.newhua.com/soft/71446.htm,下载下来解压后不用安装拷到目录下设置好即可使用。注:IIS Rewrite简单使用方法介绍:一个功能强大的URL处理引擎,功能和Apache的 mod_Rewrite类似,这个是For IIS版本 可以把像list.asp?id=234 这样的链接映射成 list/234.html 这样就有利于在GG中的排名完全版(Full)与简化版(Lite)的最大的区别在于可以让每个站点自定义URL重写规则(Rewrite Rule),也就是只要将写好的httpd.ini放在站点根目录,就能使用了。安装说明:下载后可以解压出 ISAPI_Rewrite.dll ,httpd.ini 这两个文件放到某个文件夹下面,然后在 IIS 站点属性的 ISAPI 中加载 ISAPI_Rewrite.dll就可以了, httpd.ini是配置文件里面有例子。如果加载不成功的话 请给 ISAPI_Rewrite.dll   安全属性为完全。http://support.softbar.com/uploads/allimg/101105/200F44944-0.jpg

2、在“IIS管理器”里选择网站,右键,属性。 http://support.softbar.com/uploads/allimg/101105/200F43433-1.jpg

3、选择“ISAPI”,点击“添加”。http://support.softbar.com/uploads/allimg/101105/200F43E9-2.jpg

4、填入筛选器名称,如“rewrite”。 http://support.softbar.com/uploads/allimg/101105/200F4J59-3.jpg

5、可执行文件下方点击“浏览”,选择刚才解压的Rewrite组件位置,Rewrite.dll。 http://support.softbar.com/uploads/allimg/101105/200F4F07-4.jpg
6、确认选择正确后,点击“确定”。

7、点击“确定”,完成筛选器添加。8、重启IIS。 http://support.softbar.com/uploads/allimg/101105/200F4B51-5.jpg9、重启IIS后,再次选择站点,右键,属性,看到如下所示向上的绿箭头,说明 IIS Rewrite 成功添加并运行。 http://support.softbar.com/uploads/allimg/101105/200F46350-6.jpg

IIS Rewrite 规则设置解压后的 IIS Rewrite 组件目录(如 C:Rewrite)中,有一个 httpd.ini 文件,将相应规则写入到这个文件中即可。1. 安装重写插件Rewrite.dll如果你的 IIS 服务器加载过 Rewrite.dll 则可以不用下载。Rewrite.dll文件:百度搜索关键字:Rewrite.dll 下载加载 Rewrite.dll在 IIS 的 Isapi 上添加筛选器筛选器名称为:re可执行文件选择 Rewrite.dll 就可以了!2. 配置 httpd.ini
打开你的httpd.ini,找到# 3600 = 1 hour
CacheClockRate 3600RepeatLimit 32# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^(.*)/archiver/(+.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-(+)-(+).html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-(+)-(+)-(+).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可以这样写:RewriteRule ^(.*)/html/(+)/(+).html$ $1/read.php?bl_id=$2&bu_id=$3要使你的IIS服务器支持伪静态重写,按以下步骤来:1. 安装重写插件Rewrite.dll如果你的 IIS 服务器加载过 Rewrite.dll 则可以不用下载。加载 Rewrite.dll在 IIS 的 Isapi 上添加筛选器筛选器名称为:re可执行文件选择 Rewrite.dll 就可以了!2. 配置 httpd.ini
打开你的httpd.ini,找到# 3600 = 1 hour
CacheClockRate 3600RepeatLimit 32# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^(.*)/archiver/(+.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-(+)-(+).html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-(+)-(+)-(+).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可以这样写:RewriteRule ^(.*)/html/(+)/(+).html$ $1/read.php?bl_id=$2&bu_id=$3再例:123.php?id=123
123/id/123
RewriteRule ^123/id/()/$ /123.php?id=$1
or
RewriteRule ^123/id/(+)$ /123.php?id=$1

PW的规则:
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)/simple/(+.html)$ $1/simple/index.php?$2注:比如互动百科的伪静态,设置方法和这些都是差不多的,学会这个方法了其它的一些系统的伪静态设置都是差不多的,不同的可能就是伪静态的规则设置会不一样。个人备注:这里的$1, $2, $3就是前一个表达式的匹配值比如:^(.*)/simple/(+.html)$ $1/simple/index.php?$2
页: [1]
查看完整版本: Windows服务器下IIS设置伪静态方法