LoginSignup
13
11

More than 5 years have passed since last update.

CakePHPアプリのwebrootをサブディレクトリとしてデプロイ

Last updated at Posted at 2014-05-13

環境

  • apache2.2.x
  • CakePHP2.4.7

httpd.confと.htaccessを修正

apacheのドキュメントルートはhoge/app/webrootとして、サブディレクトリをaliasする。
CakePHPアプリは/var/hogeへデプロイし、subをサブディレクトリ名とする。

httdp.conf
<VirtualHost *:80>
  DocumentRoot /var/www/html
  Alias /sub /var/hoge/app/webroot
  <Directory /var/hoge/app/webroot>
    AllowOverride All
  </Directory>
</VirtualHost>

.htaccessにRewriteBaseを追加する。

/var/hoge/app/webroot/.htaccess
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [L]
  RewriteBase /sub
</IfModule>
13
11
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
13
11