现在的位置: 首页 > 技术分享 > WordPress > 正文

IIS通过ISAPI_Rewrite完美实现WordPress伪静态

2013年11月16日 WordPress ⁄ 共 1327字 ⁄ 字号 暂无评论

WordPress默认实现的都是非静态页面,为了利于SEO,我们都会通过设置伪静态来进行优化,在Windows环境下IIS可以通过ISAPI_Rewrite完美实现Wordpress伪静态,具体操作如下:

1.首先需要下载ISAPI_Rewrite,具体地址可以百度一下,下载完成以后按默认安装即可,默认安装路径为:C:\Program Files\Helicon\ISAPI_Rewrite

2.在IIS中ISAPI筛选器添加ISAPI_Rewrite,如下图:

1

可执行文件路径如果按默认安装为:C:\Program Files\Helicon\ISAPI_Rewrite\ISAPI_Rewrite.dll

3.重启IIS

4.修改ISAPI_Rewrite规则,去掉C:\Program Files\Helicon\ISAPI_Rewrite文件夹内的httpd.ini文件只读属性,默认该文件为只读,因为我们要修改它,所以需要将其属性进行修改,然后复制一下代码:

 

[ISAPI_Rewrite] # Defend your computer from some worm attacks #RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O] # 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 /tag/(.*) /index\.php\?tag=$1

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

RewriteRule /images/(.*) /images/$1 [L]

RewriteRule /sitemap.xml /sitemap.xml [L]

RewriteRule /sitemap.html /sitemap.html [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为以上代码就完成了IIS服务器的配置,在此要注意一点 如果如果有HTML静态页面,主要是网站地图可以通过添加类似的“RewriteRule /sitemap.html /sitemap.html”规则实现其非伪静态,防止出现404错误。

5.打开Wordpress后台修改固定链接为:自定义结构 /%category%/%post_id%.html

至此就完成了IIS里Wordpress伪静态的配置工作

给我留言

留言无头像?


×