WordPress permalinks(永久链接) rewrite rules for IIS

为了这个permalinks(永久链接) 真是花费我好多的时间,从星玄宇那里知道蓝风的httpd.ini规则文件设置,但用到我WordPress上就一直没有效果,于是一直在找原因,期间让服务器的管理员帮忙覆盖文件N次,这里感激一下速度吧的技术管理员,耐心真的很好,后来我在自己机器上架了一个WordPress的运行环境,才找到了失败的原因,缺少对 UriMatchPrefix 和 UriFormatPrefix 的设置。因为我的WordPress有一层目录,所以直接把蓝风的httpd.ini文件拿过来不能直接使用。

蓝风原文 WordPress permalinks(永久链接) rewrite rules for IIS

贴一下我的 httpd.ini文件,希望对后来者有所帮助

[ISAPI_Rewrite]
 
# WordPress rewrite rules
# Design by Kevin http://www.bluefeel.com
# /%year%%monthnum%%day%/%postname%/

# UriMatchPrefix \/weblog
# UriFormatPrefix \/weblog

RewriteRule /php /phpinfo
RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /(aboutme|works|resources|guestbook|archives|sitemap|links|works|pluginsused)/ /index.php\?pagename=$1
RewriteRule /category/(.*)/(feed|rdf|rss|rss2|atom)/?$ \/weblog\/wp-feed.php\?category_name=$1&feed=$2
RewriteRule /category/?(.*)/ /index.php\?category_name=$1
 
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom)/?$ \/weblog\/wp-feed.php\?author_name=$1&feed=$2
RewriteRule /author/?(.*) /index.php\?author_name=$1
 
RewriteRule /feed/?$ \/weblog\/\?feed=rss2
RewriteRule /comments/feed/?$ \/weblog\/\?feed=comments-rss2
 
RewriteRule /page/(.*)/ /index.php\?paged=$1
RewriteRule /([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 /([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /index\.php\?year=$1&monthnum=$2&day=$3&page=$4
RewriteRule /([0-9]{4})/([0-9]{1,2})/?$ /index\.php\?year=$1&monthnum=$2&page=$3
RewriteRule /([0-9]{4})([0-9]{1,2})([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ /index\.php\?year=$1&monthnum=$2&day=$3&name=$4&feed=$5
RewriteRule /([0-9]{4})([0-9]{1,2})([0-9]{1,2})/([^/]+)/trackback/?$ \/weblog\/wp-trackback.php\?year=$1&monthnum=$2&day=$3&name=$4&tb=1
 
RewriteRule /sitemap/(.*)/ /index.php\?page_id=3&pg=$1

因为我有层目录,所以要加UriMatchPrefix 和 UriFormatPrefix 的设置
其中(aboutme|works|resources|guestbook|archives|sitemap|links)部分是对单独页面的解析,“|”分隔页面。

9 Responses to “WordPress permalinks(永久链接) rewrite rules for IIS”

  1. yqz  on 07月 12th, 2007

    http://www.pigegg.com/blog/index.php/2007/07/12/wordpress-permalinks-chinese-title-support-problem/

    能不能帮忙看一下 永久链接有问题

    回复

  2. 傻瓜  on 07月 13th, 2007

    建议给每篇文章加英文缩略名,有缩略名的文章,在使用 sample-post的时候,显示的就是你起的缩略名,而不是原来的中文标题。像你现在《我想吃肉》这篇一样,文章名《我想吃肉》缩略名i-want-meat,显示的就没有问题。

    回复

  3. David  on 12月 14th, 2007

    我的是放在一个weblog子目录下,跟目录是一个discuz论坛,应该跟你的情况差不多,不知道应该弄,能不能帮下忙

    回复

  4. 终于搞定Wordpress 2.5 permalinks rewrite rules for IIS | Jackly's blog  on 04月 1st, 2008

    [...] 为了完美的实现伪静态,快被permalinks的404错误整死了。 经过N多资料的收集,让空间商的客服和我一起忙了半天,终于在傻瓜不傻的博客上找到了一个很好了httpd.ini的解决方案。当然最早写这个httpd.ini是蓝风。 (本来用甜蚂蚁(转)的解决方案可以实现postname%.html的,可是由于没有完全看懂代码,最后被替换掉了。也不想再麻烦空间商了。) [...]

  5. defage  on 11月 21st, 2008

    我被永久链接把头搞爆炸了。我是自己的服务器,apache已经支持rewrite了,但是改成任何格式的永久练级都会找不到url,
    你这个http.ini是什么文件?apache的设置文件不是http.conf吗,怎么http.ini是放在哪的?

    回复

  6. vicmiao  on 03月 26th, 2009

    你好,我用的是WINDOWS 2003 VPS,也装了ISAPI_Rewrite组件 ,我用 Discuz 已经实现了静态化,但wordpress 就是生成不了,用了cos-html-cache 2.7.3插件。请指点一下。谢谢

    回复

  7. 乐乐猪  on 03月 27th, 2009

    @vicmiao
    不好意思,搬出国内主机后就再也不用担心Permalinks的问题,所以就没有深研究他。cos-html-cache插件我没有使用过,是国内生活点滴 东哥的作品,你可以直接咨询一下他,看看是不是可以通过这个插件不再需要重新设置Permalinks。另外,ISAPI_Rewrite组件的版本也有很大关系,07年我用Win主机的时候,Discuz 论坛提供的那个ISAPI_Rewrite组件和当时我用的ISAPI_Rewrite组件版本是不一样的。

    回复

  8. MOMO  on 03月 30th, 2009

    测试一下!!

    回复

  9. 乐乐猪  on 03月 30th, 2009

    @MOMO
    好个性的图标,呵呵,就是不知道你测试什么?只要不是自动消息发布器就行,哈哈。 :mrgreen:

    回复


Leave a Reply