AWSにcodeIgniterをいれて、mod_rewriteを設定したときの備忘録 | ぽにょ、ぽにょぽーにょ

ぽにょ、ぽにょぽーにょ

2012年からWebエンジニア。
プログラムとか、趣味とか、人生とかの備忘録。

なんかアメブロってださくて使いづらいからそのうち引っ越しまふ。

今回はapacheのmod_rewriteをつかった。

1.http://memorva.jp/memo/linux/mod_rewrite.php

httpd.confに
LoadModule rewrite_module modules/mod_rewrite.so

があることを確認

2.
<VirtualHost *:80>
  RewriteEngine On
  RewriteCond $1 !^(index\.php|images|robots\.txt)
  RewriteRule ^/hogehoge/(.*)$ /hogehoge/index.php/$1 [L]
</VirtualHost>

みたいに追加。
今回はhttp://www.xxxxx.com/hogehoge 配下にindex.phpとかがある。

最初は
 RewriteRule ^/hogehoge/(.*)$ /hogehoge/index.php/$1 [L]
ではなく、
 RewriteRule ^/hogehoge/(.*)$ /hogehoge/index.php/$1 [L,R]
ってやったら、リダイレクト後のURLにindex.phpが表示されてて消えなかった。注意。

3. application/config/config.phpで下記を直す

$config['index_page'] = 'index.php';
(修正後)$config['index_page'] = '';

これでできた。