IIS下实现WordPress伪静态

网上找了很多教程,不是标签404就是分类404,各种不靠谱,我这里有一段代码可以完美实现Wordpress 在 IIS下伪静态。

首先在说规则之前,我还是先说明下如何实现伪静态。首先在网上搜索并下载一个叫做ISAPI_Rewrite的组件,并在IIS上启用它,具体启用方法这里暂时就不说了,大家可以去网上查下,在你Wordpress网址根目录创建一个文件httpd.ini并打开,复制进下面这些代码保存即可。(注意:Wordpress后台固定连接自定义里面输入/%post_id%.html)

 

[ISAPI_Rewrite]

# Protect httpd.ini and httpd.parse.errors files

# from accessing through HTTP

# # 形式:/PostID.html

# # 自定义链接 /%post_id%.html

RewriteRule /wp-(.*) /wp-$1 [L]

RewriteRule ^/$ /index\.php [L]

RewriteRule /tag/(.*) /index\.php\?tag=$1

RewriteRule /(about|contact|about-

 

copyright|favor|diy|archives|tags|sitemap|link|search|help|security|%e5%85%b3%e4%ba%8e) 

 

/index\.php\?pagename=$1

RewriteRule /(search) /\?pagename=$1

RewriteRule /category/(.*)/(feed|rdf|rss|rss2|love|diy|talk|atom)/?$ /wp-feed\.php\?

 

category_name=$1&feed=$2

RewriteRule /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 /feed/?$ /index\.php/\?feed=rss2

RewriteRule /comments/feed/?$ /wp-feed\.php/\?feed=comments-rss2

RewriteRule /([0-9]+).html /index\.php\?p=$1 [I]

RewriteRule /page/(.*)/ /index\.php\?paged=$1

RewriteRule /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 /date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /index\.php\?

 

year=$1&monthnum=$2&day=$3&page=$4

RewriteRule /date/([0-9]{4})/([0-9]{1,2})/?$ /index\.php\?year=$1&monthnum=$2&page=$3

RewriteRule /([0-9]+).html/(feed|rdf|rss|rss2|atom) /index\.php\?feed=rss2&p=$1

RewriteRule /([0-9]+).html/trackback /wp-trackback\.php\?p=$1

如果中文分类或Tag出现乱码可以添加下面的规则

 

RewriteRule /tag/(.*)/ /index\.php\?tag=$1

发布者

Zmsky

http://xloli.net/?page_id=11

《IIS下实现WordPress伪静态》上有3条评论

发表评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.