WordPress在Windows主机下设置伪静态的方法

香港Windows主机 (626) 2015-11-26 14:38:50

一般我们使用WordPress都会将固定链接设置成伪静态的,但是WordPress却只能在LINUX系统的服务器中才能很好的使用,在Windows系统的IIS中设置伪静态会在前面加上index.php,所以无法实现真正的伪静态功能。

Windows主机下的wordpress文章的链接都是http://www.***.com/index.php/123.html类似的链,中间的index.php异常明显,这里介绍一种方法。

首页你的主机要装Rewrite 组件,现在国内很多Windows主机都有装这个了。

使用方法:桌面新建一个txt文档然后复制下面的代码,然后修改文件名为httpd.ini并上传到网站的根目录。然后去WP后台设置固定连接:/%post_id%.html

httpd.ini 中加入如下代码:

[ISAPI_Rewrite]

# 3600 = 1 hour

CacheClockRate 3600

RepeatLimit 32

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

# from accessing through HTTP

# wordpress 伪静态规则

# For tag(中文标签以及标签翻页的规则)

RewriteRule /tag/(.*)/page/(\d+)$ /index\.php\?tag=$1&paged=$2

RewriteRule /tag/(.+)$ /index\.php\?tag=$1

# For category(中文分类以及分类翻页的规则)

RewriteRule /category/(.*)/page/(\d+)$ /index\.php\?category_name=$1&paged=$2

RewriteRule /category/(.*) /index\.php\?category_name=$1

# For sitemapxml

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

RewriteRule /sitemap.html /sitemap.html [L]

RewriteRule /sitemap_baidu.xml /sitemap_baidu.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]

THE END