0

I'm about at my wits' end with mod_rewrite problems trying to deploy a CakePHP app on shared hosting with Apache 1.3. Despite using the default .htaccess files I seem to be plagued by rewrite loops and lots of trial and error hasn't really got me anywhere.

On the server my app is installed in:

/home/www/myusername/testing

Apache accesses this directory via a subdomain symlink:

/home/www/hosts/testing.mydomain.com/

My CakePHP app is on the root inside 'testing', with a dir structure like:

/home/www/myusername/testing/
    webroot/
    controllers/
    etc...        

The base .htaccess looks like (as per the defaults):

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

The webroot .htaccess looks like:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

This all seems to work on my laptop (with Apache 2.2) but gives me errors on the server because it seems to be endlessly rewriting the request. If I access the any URI, base or not, I get a 403 error with this in the Apache error log:

File name too long: access to /home/www/hosts/testing.mydomain.com/webroot/home/www/hosts/testing.mydomain.com/webroot/home/www/hosts/testing.mydomain.com/webroot/home/www/hosts/testing.mydomain.com/webroot/home/www/hosts/testing.mydomain.com/ [REPEAT FOR A LONG TIME...]

Can anyone see anything that'd lead to the endlessly appended rewrite here? I've tried a bunch of things, such as adding RewriteConds to test the uri doesn't already contain 'webroot' but nothing seems to work. I'm willing to bet it's something obvious though!

Thanks.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
mikesname
  • 141
  • 4
  • possible duplicate of [Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?](http://serverfault.com/questions/214512/everything-you-ever-wanted-to-know-about-mod-rewrite-rules-but-were-afraid-to-ask) – Chris S Apr 20 '11 at 12:49

1 Answers1

0

Must get out of the habit of answering my own questions but the act of posting to SF seems to break the logjam. Apparently what was needed was adding to each .htaccess respectively:

RewriteBase /
RewriteBase /webroot

Still not sure particularly why those directives are needed, but I suspect it's something to do with the subdomain "testing" directory relates to the document root.

mikesname
  • 141
  • 4