How do I run a CakePHP app in a sub-folder from the root domain?

Tom picture Tom · Oct 2, 2013 · Viewed 8.1k times · Source

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!

Answer

Mindaugas Norvilas picture Mindaugas Norvilas · Oct 2, 2013

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');