手机看片精品高清国产日韩,色先锋资源综合网,国产哺乳奶水91在线播放,乱伦小说亚洲色图欧洲电影

幫助中心 >  技術知識庫 >  網站相關 >  建站知識 >  WordPress 偽靜態規則(IIS/Apache/Nginx)

WordPress 偽靜態規則(IIS/Apache/Nginx)

2016-08-08 20:47:26 5685

安裝了總是詢問WordPress 的客戶總是想知道 WordPress 如何添加偽靜態規則,今天我就與大家分享一下 IIS/Apache/Nginx 三種環境下的偽靜態規則,希望對大家有所幫助。

檢測主機是否支持偽靜態的方法:在WP后臺 > 設置 > 固定鏈接,設置為 默認帶?的那種結構,然后訪問任何一篇文章,如果出現 404 錯誤,說明你的主機當前不支持 WordPress 偽靜態。

IIS偽靜態規則

IIS 環境是 Windows 主機常用的服務器環境,新建一個 txt 文件,將下面的代碼添加到文件中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[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站點的根目錄即可。

Apache偽靜態規則

Apache是 Linux 主機下常見的環境,現在一般的 Linux 虛擬主機都采用這種環境。新建一個 htaccess.txt 文件,添加下面的代碼:

1
2
3
4
5
6
7
8
<IfModule mod_rewrite.c>RewriteEngine On
RewriteBase /RewriteRule ^index.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</IfModule>

然后上傳到 WordPress 站點的根目錄,重命名為 .htaccess 即可

Nginx偽靜態規則

Nginx環境一般是Linux 主機 VPS或服務器用戶用的比較多,這些用戶一般都會自己配置Nginx,或者有專門的人幫你配置,打開 nginx.conf 或者某個站點?配置環境,比如 wpdaxue.com.conf(不同人配置的不一樣),在  server   { } 大括號里面添加下面的代碼:

1
2
3
4
5
6
7
8
9
10
11
location / {if (-f $request_filename/index.html){
                rewrite (.*) $1/index.html break;
        }if (-f $request_filename/index.php){
                rewrite (.*) $1/index.php;
        }if (!-f $request_filename){
                rewrite (.*) /index.php;
        }}

保存,重啟 Nginx 即可。


提交成功!非常感謝您的反饋,我們會繼續努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: