I'm trying to load a CakePHP application from another document root.
Here is my Apache configuration:
<VirtualHost *:443>
ServerName internet.com
DocumentRoot "/sites/internet"
...
Alias /developer "/sites/intranet/developer"
</VirtualHost>
However, when I visit internet.com/developer/cakeapp/portal
, I get a 404. If I visit intranet.com/developer/cakeapp/portal
, it works.
Working configuration for the intranet site:
<VirtualHost *:443>
ServerName intranet.com
DocumentRoot "/sites/intranet"
...
<Directory "/sites/intranet/developer/cakeapp">
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /developer/cakeapp
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_METHOD} !OPTIONS
RewriteRule ^(.*)$ app/webroot/index.php?url=$2 [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
Should I include the mod_rewrites in the internet VirtualHost configuration too? I had assume that they would translate when the intranet site would be accessed.
Note: this setup is on a development server that is configured to mimic both intranet and internet hosting. The goal is to reuse the portal site on both domains.
Update #1
Using Cake 2.4.5
Update #2
Looking at my SSL error log file, I noticed this:
File does not exist: /sites/intranet/developer/cakeapp/users
The app redirects to users/login
, so it would seem that some of this is working. Still doesn't explain the 404.
Update #3
New rewrite rules being used:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /developer/cakeapp
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/(app/webroot/)?(img|css|js)/(.*)$
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>