環境:Ubuntu Server 15.10 x64
- 首先,確定 mod_rewrite 已經開啟。
Apache 的 mod_rewrite 功能預設是關閉的,透過以下指令來啟動覆寫功能。
1sudo a2enmod rewrite - 接著,修改 Apache 的主要設定檔。
如果伺服器 Apache 配置多個網域,請找到 WordPress 對應的設定檔。
如果沒有修改過,設定檔在 Ubuntu 的預設路徑為:
1/etc/apache2/sites-available/000-default.conf - 使用 vi 或 nano 指令編輯檔案,
主要設定檔的開頭應該是 在它上方加入這段:
123<Directory "/var/www/wordpress/">AllowOverride All</Directory> - 接者重新啟動Apache
1sudo service apache2 restart - 修改.htaccess檔案,內容如下
12345678910# BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /wordpress/RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /wordpress/index.php [L]</IfModule># END WordPress
轉:http://diary.taskinghouse.com/posts/664222-resolved-wordpress-permalinks-404-error