Win+IIS 环境的 WordPress 网站,可以选择 Rewite 规则来实现伪静态。具体方法如下:
1、咨询空间商,服务器是否已开启 Rewrite 规则的支持。
2、新增 httpd.ini 文件,写入以下代码,并拷贝至网站根目录。
- [ISAPI_Rewrite]
- # 3600 = 1 hour
- CacheClockRate 3600
- RepeatLimit 32
- # Protect httpd.ini and httpd.parse.errors files
- # from accessing through HTTP
- # wordpress weijingtai
- # 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 /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]
- # For robots.txt
- RewriteRule /robots.txt /robots.txt [L]
3、到 WordPress 后台修改固定链接为 %post_id%.html 即可,当然也可以是其他的。
以上内容整理自@张戈博客