IIS配置asp伪静态教程+伪静态写法教程
教程开始第一步我们先下载一个ISAPI_Rewrite,进行安装这里使用的是精简版,够用了,ISAPI_Rewrite下载地址:http://www.isapirewrite.com/download/isapi_rwl_0055.msi下载完成后安装即可,随便装在哪里都可以,默认是装在C:\Program Files\Helicon下,要注意的是这个目录everyone要有读取权限。如果没权限会出现
Service Unavailable错误,然后我们打开Internet 信息服务,右键,web站点属性,点击ISAPI筛选器选项卡.添加筛选器,这里的名称可以自己随意填写,路径自己指定ISAPI_Rewrite.dll,然后确定.如图
IIS Rewrite 规则设置一般情况下我们的程序都是自带伪静态规则的,下面唐山网站建设给大家讲一下自定义IIS Rewrite 规则怎么写配置 httpd.ini
打开你的httpd.ini,找到
[ISAPI_Rewrite]# 3600 = 1 hour
CacheClockRate 3600RepeatLimit 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!官方提供的配置代码,注意正则格式。
1. 应用
比如,将read.php?bl_id=123&bu_id=456 伪静态成 /html/123/456.html可以这样写:RewriteRule ^(.*)/html/([0-9]+)/([0-9]+).html$ $1/read.php?bl_id=$2&bu_id=$3要使你的IIS服务器支持伪静态重写,按以下步骤来:2. 安装重写插件Rewrite.dll
如果你的 IIS 服务器加载过 Rewrite.dll 则可以不用下载。加载 Rewrite.dll在 IIS 的 Isapi 上添加筛选器筛选器名称为:re可执行文件选择 Rewrite.dll 就可以了!
3. 配置 httpd.ini
打开你的httpd.ini,找到[ISAPI_Rewrite]# 3600 = 1 hour
CacheClockRate 3600RepeatLimit 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!官方提供的配置代码,注意正则格式。
4. 应用
比如,将read.php?bl_id=123&bu_id=456 伪静态成 /html/123/456.html可以这样写:RewriteRule ^(.*)/html/([0-9]+)/([0-9]+).html$ $1/read.php?bl_id=$2&bu_id=$3再例:123.php?id=123
123/id/123
RewriteRule ^123/id/([0-9][0-9][0-9])/$ /123.php?id=$1
or
RewriteRule ^123/id/([0-9]+)$ /123.php?id=$1
PW的规则:[ISAPI_Rewrite]
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)/simple/([a-z0-9_]+.html)$ $1/simple/index.php?$2
备注:这里的$1, $2, $3就是前一个表达式的匹配值比如:^(.*)/simple/([a-z0-9_]+.html)$ $1/simple/index.php?$2中对应的颜色对应相应的值!
TAG:
评论加载中...
|