Apache是 Linux 主機下常見的環境,如今通常的 Linux 虛擬主機都採用這種環境。新建一個 htaccess.txt 文件,添加下面的代碼:php
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 便可html
Nginx環境通常是Linux 主機 VPS或服務器用戶用的比較多,這些用戶通常都會本身配置Nginx,或者有專門的人幫你配置,打開 nginx.conf 或者某個站點的配置環境,好比 wpdaxue.com.conf(不一樣人配置的不同),在 server { } 大括號裏面添加下面的代碼:nginx
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 便可。服務器