WordPress在Windows主机中如何实现伪静态
在本地测试 wordpress 的时候,使用了固定地址的伪静态,但显示的是无法显示该页,该页不存在的提示,本地使用的是 windows 主机,原来 windows 主机下是不支持伪静态的,无论是使用了伪静态的缓存插件还是直接使用固定地址来设定都是不管用的。
哪么如何来支持 wordpress 在 windows 主机中的伪静态呢,需要在根目录下新建一个名为 httpd.ini 的文件,然后在里面输入如下的代码进行保存,代码如下:
[code lang="php"]
[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 /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]
[/code]
这就是设置伪静态的代码了,同样的如果服务器端是 win 主机,同样不能实现伪静态,就需要这样来设置一下了,只要将 httpd.ini 文件上传至 wordpress 根目录下即可。
最后建议搭建 wordpress 环境最好是使用 liunx 环境系统,毕竟 wordpress 是由 php 语言写出来的嘛,而 liunx 又是 PHP 的最佳环境系统了。