LoginSignup
2
3

More than 5 years have passed since last update.

mod_rewriteの設定

Last updated at Posted at 2016-06-15

rewrite ruleを設定してみる

参考:
http://oxynotes.com/?p=7392
http://qiita.com/s2maeda/items/21d9458e44f86597d1ae
https://teratail.com/questions/1239
http://phantom37383.blog.fc2.com/blog-entry-1551.html
https://www.gidblog.com/invalid-command-rewritelog/

以下を追加

vim /etc/apache2/apache2.conf
+LoadModule rewrite_module mod_rewrite.so                                                                                                                                                                                                                                  
+RewriteLog /var/log/httpd/rewrite.log                                                                                                                                                                                                                                     
+RewriteLogLevel 9

各種設定が足りなかったら追加

cd /var/log
mkdir httpd
chmod 777 httpd
ln -s /usr/lib/apache2/modules/mod_rewrite.so /etc/apache2/

apache restartでなんか出た

ubuntu@ip-172-31-28-173:/etc/apache2$ service apache2 restart
 * Restarting web server apache2                                                                                                                                                                                                                                       [fail] 
 * The apache2 configtest failed.
Output of config test was:
AH00526: Syntax error on line 224 of /etc/apache2/apache2.conf:
Invalid command 'RewriteLog', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.

ここ参考にした
http://blog.mor-maid.info/%E6%8A%80%E8%A1%93%E7%B3%BB/%E3%80%90apache%E3%80%91%20rewritelog%E3%81%AE%E8%A8%AD%E5%AE%9A

書き方が古かったようで、apache 2.4では

LogLevel alert rewrite:trace3

としか書けないよう。(ログファイルは選べないみたい)

そしてapacheのrestart
sudo service apache2 restart

これによって
[:http_address]/contact
のようなアドレスもアクセスできるようになった

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3