- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業務經營許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯網協會理事單位
- 安全聯盟認證網站身份V標記
- 域名注冊服務機構許可:滇D3-20230001
- 代理域名注冊服務機構:新網數碼
安裝了總是詢問WordPress 的客戶總是想知道 WordPress 如何添加偽靜態規則,今天我就與大家分享一下 IIS/Apache/Nginx 三種環境下的偽靜態規則,希望對大家有所幫助。
檢測主機是否支持偽靜態的方法:在WP后臺 > 設置 > 固定鏈接,設置為 非默認帶?的那種結構,然后訪問任何一篇文章,如果出現 404 錯誤,說明你的主機當前不支持 WordPress 偽靜態。
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是 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環境一般是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 即可。
售前咨詢
售后咨詢
備案咨詢
二維碼
TOP