Problems with CakePHP and VirtualDocumentRoot

I have a LAMP server configured with DocumentRoot /var/wwwchanged to VirtualDocumentRoot /var/www/%-3/in the Apache2 configuration file - this allows me to automatically map /var/www/<subdomain>to <subdomain>.example.com.

I am currently studying CakePHP (2.x), with Cake in the directory /var/www/foo/; I noticed that URLS are not being redirected properly, and I am trying to solve this problem; according to http://bit.ly/KmEhHl, I changed the default .htaccess file (among other things):

RewriteBase /cake
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]

But this causes 500 internal server errors - checking Apache2 error.logand rewrite.logbecause it .htaccesscauses an infinite redirection and adds app/webrootto the URI.

From my point of view, the flag Lhere should indicate the "last rule" - I assume that this error is due to my poor understanding mod_rewrite, but I do not know exactly where this happens. Will there be an error due to some other hidden problem with this setting? I know that there have already been several questions about this, and will be updated if any new information can be found at my end. Any help would be greatly appreciated!

+3
source share
1 answer

Found an answer!

The full answer is kindly provided by the user "kostasz" in http://bit.ly/NSDWE2 in the comments.

- RewriteBase /cake URL.

, RewriteBase / .htaccess /, /app/ /app/webroot/.

+5

All Articles