WordPress如何在win系統下實現偽靜態

Web開發者發表於2012-05-28

  現在對於win2003的伺服器,一般主流空間商裝的都是IIS6.0的web伺服器,一般很多初級使用者都會認為win主機支援php偽靜態不太好,其實不是,是很多人不明白怎麼設定罷了,比如:WordPress如何在win系統下實現偽靜態,下面詳細給大家說下:

  首先你先問你空間商,你購買的空間支援不支援偽靜態,一般購買的付費空間/虛擬主機都是支援的。如果支援的話,就建立一個httpd.ini檔案 ,把下面程式碼儲存到該檔案中,上傳到網站的根目錄就可以了。然後,之後進入WP後臺修改固定連結,比如修改為:/%category%/%post_id%.html ,很簡單吧。

[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 /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]

  這個規則檔案的寫法是IIS6.0下最新的wordpress偽靜態規則。一般win主機都是IIS6.0的web伺服器 ,而不是Apache的,在IIS伺服器下,像一些常見的wordpress部落格、shopex網店系統等第三方知名第三方程式,偽靜態的實現,自己只需要把網站的靜態化規則檔案命名為httpd.ini檔案放在網站根目錄就可以了,無須通過網站後臺設定,那是在Linux系統下的Apache伺服器下才那樣設定的。

相關文章