我們都知道WordPress程序很強大,對搜索引擎優化很友好,但是有一點可能有些人還不是很清楚,對于WordPress這樣一款開源程序來 說,它本身就是在Linux/Apache平臺中開發,先天上與其結合得比較緊密,因此,如果可能的話,選擇Linux/Apache平臺應該是第一選 擇。盡管WordPress可以在Windows/iis平臺中安裝使用,但存大許多不足,其實中致命的一點便是IIS本身不支持Mod_Rewrite 功能,而這將會給博客的維護、管理、SEO優化帶來很多麻煩。
由于IIS不支持Mod_Rewrite,因此,Wordpress便無法實現標準的、簡潔的Permalinks,而只能采取在Url中包含“index.php“的替代方案(如SEO探索的權益之計中所探討的那樣);所以無法實現真正的偽靜態功能。
經過幾天的努力找答案終于搞定了Wordpress在win/IIS下偽靜態的功能,雖然網上有利用404.php頁面來實現的方法,但終歸沒有這種自然的好。今天就給大家分享一下,首先你的主機要裝Rewrite組件,現在國內很多WINDOWS主機都有裝這個了,如果沒有可以聯系主機空間商。然后在httpd.ini 中加入如下代碼:
代碼如下:
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
#解決中文tag無法訪問的問題
RewriteRule /tag/[^/]+)/([^/]+)/?([0-9]+)?/ /index.php?tag=$1&paged=$3 [L]
# 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]
但是修改之后中文tag又不能訪問了,別擔心,接著看下一步。
修改wp-include中的classes-wp.php,之前版本可能是classes.php。
原代碼:
$pathinfo = $_SERVER['PATH_INFO'];
替換為:
$pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], "UTF-8", "GBK");
原代碼:
$req_uri = $_SERVER['REQUEST_URI'];
替換為:
$req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK");
修改后,保存下,然后將保存后的文件上傳并覆蓋原文件即可,這里需要注意文件保存格式。
然后在固定鏈接中設置為自己想要的就可以了。
附:常用WordPress固定鏈接格式
1)/%postname%/
2)/%year%/%monthnum%/%postname%/
3)/post/%post_id%.html
4)/%year%/%monthnum%/%day%/%postname%/
5)/%year%/%monthnum%/%day%/%postname%.html
新聞熱點
疑難解答