WordPress用Windows主機設定偽靜態方法
WordPress本身是p?的形式,應該大多數都還是會選擇自定義連結吧。
下面是windows主機的偽靜態規則,因為我伺服器是windows的。。。
[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]
儲存為httpd.ini,將檔案上傳到你的WordPress安裝目錄,然後設定固定連結。網上一大批的規則,隨便找下就有。
通常我們自定義URL形式為:
域名/分類別名/文章ID.html
如果這樣就選擇自定義結構選項,填寫:
/%category%/%post_id%.html 我是直接用的/%post_id%.html,我喜歡簡潔。
也可以自己搭配,你覺得喜歡就行,當然得合理:
%year%:文章發表的年份,四位數字,如2014
%monthnum%:文章發表的月份,如09
%day%:文章發表的日期,如13
%hour%:文章發表的時間(小時),如10
%minute%:文章發表的時間(分鐘),如01
%second%:文章發表的時間(秒),如46
%postname%:文章別名,在發表文章時可以設定。
%post_id%:文章的ID,如154
%category%:分類別名,在新增分類時可以設定。
%tag%:標籤的別名,在新增標籤時可以設定。 具體可以參考WordPress的設定說明。 PS:在Windows主機下設定WordPress偽靜態有時會遇到一些小問題問題,所以很多人推薦WordPress搭建網站最好選用Linux主機。 我用的windows伺服器,各有各的好處吧,畢竟我網站全是用的windows伺服器。