index.phpの置き場所と設定方法とURL
環境
Zend Framework: 1.11.0 rc1
ProjectRoot:/usr/share/project
設定ファイルはCentOSのルールによる
目的
Zend FrameworkのチュートリアルだとVirtualHostを使う設定になっている。*1
でも、、サブディレクトリで運用したいんだ。
http://www.example.jp/zfapp/ みたいな。
httpd.confの設定 Alias作成
httpd.confを直接編集してもいいけれど、
せっかくなので /etc/httpd/conf.d/project.conf を作ってみる。
/etc/httpd/conf.d/project.conf
Alias /zfapp /usr/share/project/public <Directory "/usr/share/project/public"> AllowOverride All Order Deny,Allow Allow from all </Directory>
.htaccessの編集 rewritebaseの追加
publicにおいてある.htaccessにRewriteBaseを追加する
project/public/.htaccess
RewriteEngine On RewriteBase /zfapp/ RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L]