どうも
http://TEST.COM/index.php/posts/edit
とか
/index.php/が出ちゃう。mod_rewrite使えるようにしてるのに。と思ったら
mod_rewriteが使える設定と使えない設定を両方ごっちゃにやってたみたいw
CakePHPでmode_rewriteが使えない場合は、
core.phpの
//Configure::write(‘Routing.admin’, ‘admin’);
のコメントアウトを外して
以下3つの.htaccessを削除もしくはリネームする
/.htaccess
/app/.htaccess
/app/webroot/.htaccess
ということなので
CakePHPでmod_rewriteが使える場合は、
care.phpも3つの.htaccessもデフォルトのままでやれば
/index.php/無しのURLになる。
/index.php/が入る部分の記述は、
/app/webroot/.htaccessの
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
!-dは、ディレクトリが無ければ、
!-fは、ファイルが無ければ、
index.phpへ処理を渡すという指定。
RewriteRuleに合致するファイルやディレクトリが実在する場合は、RewriteRuleを適用しなくなる。
※RewriteCondはRewriteRuleごとに必要。
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
で、/index.php/に関する指定。
webroot直下
/にアクセスすると、/index.php/?以降のファイルを表示する。
rewriteしてるので
/posts/editになるが、
/index.php/posts/editも存在する。
元々のwebroot/index.phpは存在するので
rewrite_ruleは適用されず、
ドメイン/では表示されず、
ドメイン/index.phpで表示される。
Cakephpのurl内のindex.php2
04
1月
2010
0