サブディレクトリの設定方法

zendframeworkをサブディレクトリで利用する方法。ドキュメントルートばかりではなく、サブディレクトリでも使われることが多いのでメモ。

http://test.com/sub/の場合

■index.php

 

$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory('コントローラーのパス');
$router = new Zend_Controller_Router_Rewrite();
$front->setRouter($router);
$front->setBaseUrl('/sub');
$front->dispatch();
 
■htaccess
RewriteBase /sub/
RewriteEngine on
RewriteRule !.(js|ico|gif|jpg|png|css|flv|html|php|csv)$ index.php

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です