I have a ZendFramework project that I would like to run inside a subdirectory.
Currently my document root is at /var/www and the project is at /var/www/project with the various folders (controllers, public, etc.) all within the project directory.
I am trying to make it so that all requests from http://webserver/project/* are being passed to the /var/www/project/public/index.php file. However, trying to use the following code in /var/www/project/.htaccess to pass all requests does not work:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /project/public/index.php [NC,L]
There is also an .htaccess file in /var/www/project/public that contains exactly the same code, but when loading the /project URL I am just presented with a directory index of the project contents.
I’d store the project completely separate to the document root, for example
/home/user/projects/project.Then, simply symlink
/var/www/projectto/home/user/projects/project/public.Provided you use the BaseUrl view helper for any static asset links (JavaScript, images, CSS, etc), it should work just fine.
Edit: Another suggestion is to separate your public directory from the rest of the application.
For example, say your project is in
/home/user/projects/project, move the contents of yourpublicdirectory to/var/www/projectand editindex.phpwith the following