Does anyone know exactly what happens when you change your Zend site at, say, foo.com/
to foo.com/subfolder/
? I notice that routing breaks and either I am not using front_controller.setBaseUrl()
properly or it has no effect. I am unable to find any formal documentation at the Zend site about this issue.
views:
198answers:
3You need to make sure you prepend the /newfolder/ to all your set_include_path statements in the config. Then setBaseURl should work properly.
The most likely cause of your problem is that you need to set the RewriteBase
parameter in your .htaccess
file.
Assuming your rewrite rules look something like this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
And assuming you are moving your site into the subfolder
subfolder, add the following line to your re-write rules, just under RewriteEngine on
.
RewriteBase /subfolder
Your complete rewrite rules should look like so:
RewriteEngine on
RewriteBase /subfolder
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
PS: The Front Controller/Request Object/Router will 99% of the time correctly determine the baseUrl
automagically. Try not explicitly setting it. If the above changes to your rewrite rules do not work, only then attempt to override.
You can, at any time get the baseUrl
that was determined be the request with the following:
var_dump(Zend_Controller_Front::getInstance()->getBaseUrl());