I have installed zend framework on my local machine. I have configured a vhost in httpd.conf and have added a line in my hosts file (127.0.0.1 mysite). I am running windows 7. Everything works perfect. The problem is when i upload on a hosting server the paths get mixed up. I am uploading on a remote dir called zf-framework. To access the index page i need to type this url: http://mysite/zf-framework/public. It displays the index page but when i press any links on the page they get mixed up and end up being something like http://mysite/controller/action when in fact it should be http://mysite/zf-framework/public/controller/action. I have found a work-around for this situation...to use echo $this->baseUrl(link) for any links i have in the layout.phtml. The problem is more serious when it comes to submitting forms. I can't use baseUrl there....or i don't know how to use it. Is there a way to write some general config stuff so that this could be automatically resolved by the framework. Let's say to write something in index.php or bootstrap.php that will fix the paths automatically?
I am not 100% on this, but if you specify the route in your routes.ini as zf-framework/public/Controller/Action etc this should fix your issue.
I would see this as a bandaid, but I am not 100% sure on how to properly fix your issue other then you modifying the vhosts file on the remote server to set a document root to the public folder. If that is not an option, well the above should work, but know that all of your files are potentially accessible from everyone (at least your folder structure). I am not sure what harm this can do (if any) other then if your database schema is in the /data directory.
It is better to try and get the public set as the web root, if possible.
If you're using Zend_Application, then add the following to your configs/application.ini file.
resources.frontController.baseUrl = "/your-path-here"
If you're not using Zend_Application, then do this in your bootstrap, or index.php file.
$front = Zend_Controller_Front::getInstance();
$front->setBaseUrl('/your-path-here');
You won't have to use $this->baseUrl() when submitting a form to the same action and controller (just leave out the action attribute in the form tag), or when using the Redirector action helper. However, links in your view scripts will require you to $this->baseUrl('/url-without-base'), which doesn't seem too bad to me.