Question

I'm trying to setup a CakePHP app in a sub-folder but run it from the root domain, eg, user requests domain.co.uk and they get the webroot at {DOCUMENT_ROOT}/version-13/app/webroot.

The hosting setup doesn't allow me to change the document root so I have the following .htaccess in the root:

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

This appears to do the job. However, Cake detects the sub-folder and adds it to all the URLs it creates (eg, $this->Form->create() actions, etc) so I end up with forms posted to domain.co.uk/version-13/signup instead of domain.co.uk/signup.

I know this is probably going to be something simple but I'm hitting a brick wall. No matter what I try I can't get it to work!

Was it helpful?

Solution

It's hard to understand your setup, you should explain it more. But if I got it right, check /app/Config/core.php:

Configure::write('App.fullBaseUrl', 'http://example.com');

OTHER TIPS

Change your RewriteBase / to RewriteBase /version-13/ (in your .htaccess)and you should be set right up.

I had the exact same issue when I didn't have my local server set up correctly, which forced me to put my applications in a folder of my main domain.

Please note that you can have multiple apps at one core. This could be useful for you "versioning".

Ps. after a quick Google search I found the following. Didn't read it that well, but it looks like it does the same. http://cookingwithcakephp.blogspot.nl/2008/04/installing-cakephp-into-subdirectory.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top