wordpress 2.2的Url Rewrite规则
刚从PJBlog搬家过来的时候,由于原来未使用过wordpress,而且在之前也没有认真看wordpress需要的服务器配置,以致刚搭建的博客就遇到了第一个问题:url自定义的rewrite问题。
在后台永久链接自定义处输入/%category%/%postname%.html之后,打开前台页面总是404错误,到wordpress中文论坛咨询过后得知这是由于空间不支持rewrite造成的。
再然后就是与空间商的沟通,我找到了wordpress 2.2版本的rewrite规则,让他在服务器上帮我设置了才能达到伪静态的目的。美中不足的是,生成的html页面url中总是有index.php这么个东西,上网找了很多解决办法,总之都是空间的问题了,也不打算去改它了,url在SEO中的作用并不太大,而且访客一般也不会在意url结构问题。
我找的Url Rewrite规则来自甜蚂蚁的部落格,根据我的情况我自己修改了一下,内容如下代码问题,其中红色部分是我的url自定义结构。
最后一个问题就是为什么我的文章中总是要带着index.php,如果url自定义结构中没有包括index.php的话,则前台所有文章和类别页面都是404错误。论坛上的人说这是由于空间不支持mod_rewrite造成的。百思不得其解,如果有人知道,麻烦告诉我一下,在下面留言即可。
使用办法如下:
1、在Wordpress后台的永久链接处,选择自定义结构,写入自己想要的格式,注意与上面的红色部分相符;
2、给IIS加载URL_Rewrite模块,然后httpd.ini中的内容使用下面的内容即可。
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP# # WordPress rewrite rules# /index.php/%category%/%postname%.html
RewriteRule /tag/(.*) /index.php?tag=$1
RewriteRule /(about-copyright|favor|archives|tags) /index.php?
pagename=$1
RewriteRule /post/category/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?
category_name=$1&feed=$2
RewriteRule /post/category/?(.*) /index.php?category_name=$1
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?
author_name=$1&feed=$2
RewriteRule /author/?(.*) /index.php?author_name=$1
RewriteRule /rss.xml /wp-feed.php/?feed=rss2
RewriteRule /feed/?$ /wp-feed.php/?feed=rss2
RewriteRule /comments/feed/?$ /wp-feed.php/?feed=comments-rss2
RewriteRule /([0-9]+)/?([0-9]+)?/?$ /index.php?p=$1&page=$2
RewriteRule /post/([0-9]+).html /index.php?p=$1 [I]
RewriteRule /page/(.*) /index\.php\?paged=$1
RewriteRule /post/date/([0-9]{4})([0-9]{1,2})([0-9]{1,2})/([^/]+)/?([0-9]+)?/?$
/index.php?year=$1&monthnum=$2&day=$3&name=$4&page=$5
RewriteRule /post/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /index.php?
year=$1&monthnum=$2&day=$3&page=$4
RewriteRule /post/date/([0-9]{4})/([0-9]{1,2})/?$ /index.php?
year=$1&monthnum=$2&page=$3
RewriteRule /post/([0-9]+).html/(feed|rdf|rss|rss2|atom)/ /index.php?
feed=rss2&p=$1
RewriteRule /post/([0-9]+).html/trackback/ /wp-trackback.php?p=$1
RewriteRule /photo/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?$ /wp-
content/plugins/fgallery/fim_photos.php?$1=$2&$3=$4 [QSA,L,I]
RewriteRule /photo/?(.*) /wp-content/plugins/fgallery/fim_photos.php?
$1=$2&$3=$4 [QSA,L,I]



[回复此评论]
黄海均 reply on 2008年7月23日 23:17:05
[回复此评论]