IIS下如何实现静态化重写?特别是像zen cart等php类型的网站应该是经常碰到。一下教程也是网上找到的,实验下可以成功,这边分享下。

第一:首先我们需要下载一个ISAPI_Rewrite,有精简版和完全版,一般精简版只能对服务器全局进行配置,而完整版可以对服务器上的各个网站进行伪静态配置.对于个人站长来说,精简版就足够了.下载:http://www.isapirewrite.com/download/isapi_rwl_0055.msi

第二:下载完成后,可以找到安装包里的.msi的文件,安装即可.随便装在哪都可以,默认是装在C:\Program Files\Helicon下,要注意的是这个目录everyone要有读取权限。我就因为当时服务器权限配的比较严格,默认安装Helicon这目录EVERYONE是没有任何权限的,结果老是出现:Service Unavailable。

第三:打开Internet信息服务,右键,web站点属性,点击ISAPI筛选器选项卡.添加筛选器,这里的名称可以自己随意填写,路径自己指定ISAPI_Rewrite.dll,然后确定。筛选器成功后会显示一个绿色像上的箭头。

最后在你安装目录下,默认C:\Program Files\Helicon\ISAPI_Rewrite 下编辑httpd.ini 这里写入你的重写规则,注意该文件默认为只读,所以编辑好后,最好设回只读,如果是zen cart的如下:

[ISAPI_Rewrite]
# 3600 = 1 hour 设置缓存时间 1个小时
# Www.YOURDOMAIN.Com
CacheClockRate 3600
# 设置正则表达式 替换变量个数.
RepeatLimit 32
# www.YOURDOMAIN.com
RewriteRule ^(.*)-p-(.*).html(\?)?(.*)? /index\.php\?main_page=product_info&products_id=$2&$4 [L]
RewriteRule ^(.*)-c-(.*).html(\?)?(.*)? /index\.php\?main_page=index&cPath=$2&$4 [L]
RewriteRule ^(.*)-m-([0-9]+).html(\?)?(.*)? /index\.php\?main_page=index&manufacturers_id=$2&$4 [L]
RewriteRule ^(.*)-pi-([0-9]+).html(\?)?(.*)? /index\.php\?main_page=popup_image&pID=$2&$4 [L]
RewriteRule ^(.*)-pr-([0-9]+).html(\?)?(.*)? /index\.php\?main_page=product_reviews&products_id=$2&$4 [L]
RewriteRule ^(.*)-pri-([0-9]+).html(\?)?(.*)? /index\.php\?main_page=product_reviews_info&products_id=$2&$4 [L]
# For Open Operations Info Manager
# Www.YOURDOMAIN.Com
RewriteRule ^(.*)-i-([0-9]+).html(\?)?(.*)? /index\.php\?main_page=info_manager&pages_id=$2&$4
# For dreamscape”s News &Articles Manager
# Www.YOURDOMAIN.Com
RewriteRule ^news/?$ index\.php\?main_page=news&[L]
RewriteRule ^news/rss.xml /index\.php\?main_page=news_rss&[L]
RewriteRule ^news/archive/? /index\.php\?main_page=news_archive&[L]
RewriteRule ^news/([0-9]{4})-([0-9]{2})-([0-9]{2}).html(\?)?(.*)? /index\.php\?main_page=news&date=$1-$2-$3&$5 [L]
RewriteRule ^news/archive/([0-9]{4})-([0-9]{2}).html(\?)?(.*)? /index\.php\?main_page=news_archive&date=$1-$2&$4 [L]
RewriteRule ^news/(.*)-a-([0-9]+)-comments.html(\?)?(.*)? /index\.php\?main_page=news_comments&article_id=$2&$4 [L]
RewriteRule ^news/(.*)-a-([0-9]+).html(\?)?(.*)? /index\.php\?main_page=news_article&article_id=$2&$4 [L]
# All other pages
# Www.YOURDOMAIN.Com
# Don”t rewrite real files or directories
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html(\?)?(.*)? /index\.php\?main_page=$1&$3 [L]
# Www.YOURDOMAIN.Com
说明及声明:前面说明过ISAPI_Rewrite有精简版和完全版之分,前面的地址貌似是精简版的,所以估计会对iis下的所有网站产生作用,使用的时候注意,网上有完整版的破解版,但是自己没有使用过也不好说;这份Zen cart的重写规则我并没有自己动手验证过,是朋友给我的,所以拷贝使用的时候明白下这点。
 

转载请注明来自: http:www.ming-seo.org/?p=418

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。