I have a LAMP server configured with DocumentRoot /var/www changed to VirtualDocumentRoot /var/www/%-3/ in the Apache2 config file – this allows me to automatically map /var/www/<subdomain> to <subdomain>.example.com.
I’m currently in the process of learning CakePHP (2.x), with Cake in directory /var/www/foo/; I’ve noticed that the URLS aren’t redirecting properly, and am attempting to resolve this issue; as per http://bit.ly/KmEhHl, I’ve modified the default .htaccess file to (among other things):
RewriteBase /cake
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
But this raises a 500 Internal Server Error – checking Apache2’s error.log and rewrite.log, this is because .htaccess is causing an infinite redirect, and is appending app/webroot to the URI.
From my understanding, the L flag here should indicate ‘last rule’ – I’m assuming that this error is due to my poor understanding of mod_rewrite, but I’m not sure exactly where this is happening. Would the error be because of some other latent issue with this setup? I’m aware that there have been several questions on this already, and will update if any new information can be found on my end. Any help would be greatly appreciated!
Found an answer!
Full answer courtesy of user ‘kostasz’ at http://bit.ly/NSDWE2 in comments.
The hint was indeed the infinite redirect – using
RewriteBase /cakewas not the correct base URL.To fix this issue, add
RewriteBase /to each of the.htaccessfiles in/,/app/, and/app/webroot/.