WordPress在Windows服务器的伪静态规则

这两天帮客户在Windows服务器上设置WordPress的伪静态url,但是客户的主机并不支持WordPress后台直接设置静态url,因此比较麻烦,需要用到IIS的配置文件httpd.ini来设置重写规则,从而实现WordPress的url静态化。

下面将伪静态规则记录下来,使用的方法是新建一个文本文件,将下面代码拷入,然后存储为httpd.ini 文件,上传到网站根目录即可。此外,多说一句,php程序(如WordPress),还是尽可能不要选择windows主机,不仅配置麻烦,而且解析php的效率也相对低一点。

[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default.ida|root.exe|..).* . [F,I,O]
# 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 /tag/(.*) /index.php?tag=$1
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
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]

相关文章: