wordpress在win主机iis下实现伪静态的方法

2010年11 月25日 / 网站源码 / 没有评论 / 1,895次

我的博客是放在windows主机下的,大家都知道一般我们使用wordpress都会将固定链接设置成伪静态的,但是WP却只能在LINUX系统的服务器中才能很好的使用,在windows系统的iis中设置伪静态会在前面加上index.php,所以无法实现真正的伪静态功能。

看了萧涵大哥的文章后,终于搞定了wordpress在IIS下伪静态的功能,win下伪静态的设置方法有很多种,网上有利用404.php页面来实现的方法,但是本人觉得终归没有这种自然的好。

首先你的主机要装Rewrite 组件,现在国内很多windows主机都有装这个了。如果是你自己的主机的话,你需要在httpd.ini 中加入如下代码即可(如果不是自己的主机,那么你只需要把下面的规则代码发给服务器管理员,然后他就知道怎么做了,像我就是直接将伪静态规则发给华夏名网的技术员):

[ISAPI_Rewrite]

# 3600 = 1 hour

CacheClockRate 3600

RepeatLimit 32

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

# from accessing through HTTP

# Rules to ensure that normal content gets through

RewriteRule /sitemap.xml /sitemap.xml [L]

RewriteRule /favicon.ico /favicon.ico [L]

# For file-based wordpress content (i.e. theme), admin, etc.

RewriteRule /wp-(.*) /wp-$1 [L]

# For normal wordpress content, via index.php

RewriteRule ^/$ /index.php [L]

RewriteRule /(.*) /index.php/$1 [L]

然后在固定链接中设置为自己想要的就可以了,我的自定义链接形式就是/%postname%.html这样的,效果就是你的域名+你自己设置的文章名.html? 经过本人的测试没有发现任何错误。