パーマリンク設定変更でリンクエラーになるときの対処
ubuntu14.04 64bit で wordpress をインストールし
パーマリンクの設定を変更後
リンクをしているか調べたけど動作していないので
設定確認
まず mode_rewrite の有効化
1 | sudo a2enmod rewrite |
で
1 | Module rewrite already enabled |
ですでに有効化されているので問題なし
次に設定ファイルへの追記
1 | sudo vim /etc/apache2/sites-available/000-default .conf |
で設定ファイルを開き
1 2 3 4 5 | <Directory /var/www/html/wp/ > AllowOverride All Order allow,deny allow from all < /Directory > |
を最後に追記
設定反映のため apache2 再起動
これでもまだだめなので
.htaccess を wordpress をインストールしたディレクトリに作成
1 2 | cd /var/www/html/wp/wordpress/ touch .htaccess |
書き込み権限がOKなら
これで終わりだけど、権限がないため
ダッシュボードでパーマリンクの設定で
1 2 3 4 5 6 7 8 | <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wp/wordpress/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wp/wordpress/index .php [L] < /IfModule > |
を追記するようにでているので
1 | vim .htaccess |
で
1 2 3 4 5 6 7 8 | <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wp/wordpress/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wp/wordpress/index .php [L] < /IfModule > |
を追記して保存
これで無事に記事のリンクが可能になります