WordPress僞靜態規則設置教程

想必都瞭解WodPess和其他網站系統不一樣,其它網站系統基本都帶有生成靜態頁面功能。但WodPess只能使用僞靜態。在這就不做過多介紹了,下面就來說說WodPess僞靜態規則設置教程。

僞靜態:即網站本身是動態網頁如.php、.sp、.spx等格式,而這類網頁還帶“?”加參數來讀取數據庫。開啓僞靜態後,動態網頁即被轉換重寫成靜態網頁類型頁面。

如何判讀空間是否支持僞靜態。在網站後臺:設置-固定鏈接,選擇第一個除外,看網站其它頁面是否出現404,如果是,則空間不支持僞靜態。

只要空間支持僞靜態重寫URL Rewite功能,根據服務器主機空間環境,只需加入下列僞靜態規則即可。

一、Apche僞靜態規則

新建一箇 txt 文件,將下面的代碼添加到文件中,然後另存爲.htccess文件,上傳到WodPess站點的根目錄即可。

<IfModule mod_ewite.c>

RewiteEngine On

RewiteBse /

RewiteRule ^index\.php$ R [L]

RewiteCond %{REQUEST_FILENAME} !-f

RewiteCond %{REQUEST_FILENAME} !-d

RewiteRule . /index.php [L]

</IfModule>

二、Nginx規則

在Nginx中的see模塊配置如下內容,打開 nginx.conf 或者某個站點的配置環境,例如 /us/locl/nginx/conf/yzipi.conf,在see{ } 大括號裏面添加下面的代碼。

loction / {

if (-f $equest_filenme/index.html){

ewite (.*) $/index.html bek;

}

if (-f $equest_filenme/index.php){

ewite (.*) $/index.php;

}

if (!-f $equest_filenme){

IIS僞靜態規則ewite (.*) /index.php;

}

}

三、IIS僞靜態規則

新建一箇txt文件,將下面的代碼添加到文件中,然後另存爲 httpd.ini 文件,上傳到WodPess站點的根目錄即可。

[ISAPI_Rewite]

# Defend you compute fom some wom ttcks

#RewiteRule .*(?:globl.s|defult\.id|oot\.exe|\.\.).* . [F,I,O]

# 3600 = hou

CcheClockRte 3600

RepetLimit 32

# Potect httpd.ini nd httpd.pse.eos files

# fom ccessing though HTTP

# Rules to ensue tht noml content gets though

RewiteRule /tg/(.*) /index\.php\?tg=$

RewiteRule /softwe-files/(.*) /softwe-files/$ [L]

RewiteRule /imges/(.*) /imges/$ [L]

RewiteRule /sitemp.xml /sitemp.xml [L]

RewiteRule /ficon.ico /ficon.ico [L]

# Fo file-bsed wodpess content (i.e. theme), dmin, etc.

RewiteRule /wp-(.*) /wp-$ [L]

# Fo noml wodpess content, i index.php

RewiteRule ^/$ /index.php [L]

RewiteRule /(.*) /index.php/$ [L]

以上就是關於WodPess僞靜態規則設置教程介紹,希望對有些小夥伴有所幫助,更多有關於WodPess教程可以參考:WodPess使用教程