how to remove "public/" from http://localhost/myscript/public/ in Zend Framework
By default my script is accessible by using this url http://开发者_StackOverflowlocalhost/myscript/public/. But i need to access it by this url http://localhost/myscript/. How can i do this in Zend Framework.
The "public" folder is an important key feature of the Zend Framework because it confines Apache to only read files in that directory and, if used properly, would keep all your other code outside public visibility. If you are indeed putting your entire application up and you have to do /public/index.php to get where you want to go, you should be aware of this.
Typically, in a shared hosting configuration, you will have a public folder for your site and you separate your public folder from the rest of your application. Say for instance you have a "public_html" folder in your directory, and that is the visible folder for your domain. Then, following that logic, instead of putting everything you wanted into your home directory, you "install" your application into a custom made sub-directory called "zend_app". You would copy the files from "public" into the "public_html" folder, copy the rest of the files into the "zend_app" folder and customize your index.php file apprioriately, for example:
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../zend_app/application'));
Most of the other zend configuration is derived from that definition so it's fairly safe to build from that. If you keep that in mind when configuring your application, you can help maintain this portability. In theory, using this, you should be able to construct a configuration that would work for your needs.
- http://forums.zend.com/viewtopic.php?f=69&t=2029
- Zend Framework Path Problems
simply create a virtualhost using your webserver and configure it to use the folder "public" as the document-root and you'll be fine and secure.
just put all files from the public folder into the root folder.
then open the index.php or bootstrap.php, where ever you have this code
set_include_path(‘.’
. PATH_SEPARATOR . get_include_path()
. PATH_SEPARATOR . ‘../library’
. PATH_SEPARATOR . ‘../application/classes/’
. PATH_SEPARATOR . ‘../application/models/’
and change it to this one
set_include_path(‘.’
. PATH_SEPARATOR . get_include_path()
. PATH_SEPARATOR . ‘library’
. PATH_SEPARATOR . ‘application/classes/’
. PATH_SEPARATOR . ‘application/models/’
but check other pathes too, like this one.
require_once 'Zend/Controller/Front.php';
Got this tutorial from this page :) http://www.fincha.com/blog/2010/tutorial-zf-public-verzeichnis-umgehen-nicht-verwenden/
Its in German...
精彩评论