wordpress在windows主机下通过ISAPI_Retwrite使用固定链接

本站基于最新的wordpress3.8版建立,在本机上用xamp安装好后能显示固定链接如http://www.binfensoft.cn/archives/69等格式。但上传到虚拟主机空间后发现不行了,变成了http://www.binfensoft.cn/index.php/archives/69,网址中间多了个index.php。后经过上网了解,要让wordpress实现很好看的固定链接,必须是运行在linux主机,Apache开启Mod_Rewrite服务才行,好在Windows主机大都提供ISAPI_Retwrite功能,通主上传httpd.ini文件一样可以实现固定链接。

先持一下Wordpress自动生成的.htaccess文件吧:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress

现在要转换成ISAPI_Rewrite支持的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]
RewriteRule /sitemap_baidu.xml /sitemap_baidu.xml [L]
RewriteRule /sitemap.html /sitemap.html [L]
RewriteRule /archivers/(.*) /archivers/$1 [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# 自定义的文件夹,排除在外
RewriteRule /js(.*) /js$1 [L]
RewriteRule /voddemo(.*) /voddemo$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]

以上代码已通过验证,真实有效。

听说,最新版的ISAPI_Rewrite3.0已支持.htaccess格式规则,就是说可以不用转换,如果你的服务器支持,可以试一下。