apache2でmod_rewriteを有効にする(.htaccessを使わないパターン)

シェアする

  • このエントリーをはてなブックマークに追加
  • 0

このブログのWordPressのパーマリンク指定をデフォルト以外に変更した時に投稿ごとやカテゴリごとのページが404エラーになってしまい、mod_rewriteの有効化したときにハマったので、設定方法をメモ。
ubuntuって、どんだけ設定ファイルの場所とか名前が違うのかと
ともあれ、ubuntu14では以下の手順

1.mod_rewriteを有効にする。

root@hoge# a2enmod rewrite

2.mod_rewriteを有効にしたいディレクトリのAllowOverrideをAllにする。

root@hoge# vi /etc/apache2/site-enabled/000-default.conf

 ServerAdmin webmaster@localhost
 DocumentRoot /var/www/html
 <Directory /var/www/html>
     Options Indexes FollowSymLinks MultiViews
     AllowOverride None
     Order allow,deny
     allow from all
 </Directory>
 <Directory /var/www/html/hogehoge> ←http://domain/hogehogeの mod_rewriteを有効にする
     Options Indexes FollowSymLinks MultiViews
     AllowOverride All
     Order allow,deny
     allow from all
 </Directory>

3.apache2を再起動する。

root@hoge# service apache2 restart

シェアする

  • このエントリーをはてなブックマークに追加

フォローする