邹平人才网招聘会:IIS主机下 利用httpd.ini实现wordpress页面的伪静态化

来源:百度文库 编辑:九乡新闻网 时间:2024/05/04 14:01:43

使用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格式的吧!~