IIS主机下 利用httpd.ini实现wordpress页面的伪静态化

  • A+
所属分类:wordpress

使用Wordpress程序的童鞋,应该知道Wordpress是要用.htaccess实现伪静态化。但是万一是windows IIS的主机呢? 其实也不怕,一般IIS主机也是支持Rewrite组件的,只是要用httpd.ini来实现。他们的规则不一样,在IIS主机下需要建立如下的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]
# 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]

将以下代码写入httpd.ini,上传到根目录就行了。 本站测试是通过,还有一个规则我也是网上找的,也放出来大家可以都去试下。
规则二:

[ISAPI_Rewrite]
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# # 形式:/PostID.html
# # 自定义链接 /%post_id%.html
RewriteRule /Tags/(.*) /index.php?tag=$1
RewriteRule /(about|contact|tags|sitemap|link|) /index.php?pagename=$1
RewriteRule /Category/(.*)/(feed|rdf|rss|rss2|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 /comments/feed/?$ /wp-feed.php/?feed=comments-rss2
RewriteRule /([0-9]+).html /index.php?p=$1 [I]
RewriteRule /page/(.*)/?s=(.*) /index.php?s=$2&paged=$1
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

看似长且麻烦,针对的是文章用%post_id%.html格式的吧!

本站使用的就是这个格式,使用的规则是规则二,亲测可用,您浏览的就是使用的规则二。

wordpress伪静态下载

  • 我的微信小程序
  • 长按二维码识别查看微信小程序
  • weinxin
  • 我的个人微信号
  • 长按识别加我个人微信号
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: