harryg
harryg

Reputation: 24077

URL rewriting for cakephp on local OSX apache

I have set up apache on OSX for local web dev use and made a dynamic vhost using dnsmasq such that visiting foo.dev will point to the /foo directory in my ~/Sites/sites folder.

This is what the vhost rule looks like:

<Virtualhost *:80>
VirtualDocumentRoot "/Users/harryg/Sites/sites/%1"
<Directory "/Users/harryg/Sites/sites">
   Order allow,deny
   Allow from all
   Options Indexes FollowSymLinks Includes ExecCGI
   # New directive needed in Apache 2.4.3: 
   Require all granted
   AllowOverride All
   Satisfy Any
</Directory>
ErrorLog "/Users/harryg/Sites/logs/sites/error.log"
CustomLog "/Users/harryg/Sites/logs/sites/access.log" common
ServerName sites.dev
ServerAlias *.dev
UseCanonicalName Off
</Virtualhost>

This all works great but I donwloaded a copy of cakephp and put it in a directory ~/Sites/sites/cake. When I visit http://cake.dev I get taken to the cakephp default app page which is expected but there is a warning about url rewriting not being properly configured and stylesheets etc do not load. I followed the guide and tried placing the following in the .htaccess for the cake directory:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$ app/webroot/    [L]
    RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

But I then get a 500 Internal Server Error. Error log says:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

Suggesting the rewriting rules are conflicting somehow. Any idea how to solve this?

Upvotes: 0

Views: 700

Answers (1)

harryg
harryg

Reputation: 24077

Solved. The answer was to simply add the following line to my .htaccess files:

RewriteBase /

Not sure why it's necessary but it worked!

Upvotes: 2

Related Questions