I'm having trouble setting up httpd.conf or .htaccess files to recognize multiple zend framework sites on the same server.
For development, I have only one server, and I'm trying to configure sites so that I can access them, for example localhost / app1, localhost / app2, etc.
So, right now, when I go to localhost / app1, it successfully redirects to localhost / app1 / public / index.php, however, when I go to localhost / app1 / index / index, I get 404.
Here is my vhosts file:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot "/var/www" <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "/var/www/app1/public"> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog logs/error.log CustomLog logs/access.log common </VirtualHost>
and here is my .htaccess file from the / var / www / app 1 directory:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ /app1/public/index.php [NC,R,L]
If I changed the DocumentRoot line in the vhosts file to DocumentRoot "/var/www/app1/public"
, then application 1 will work correctly, but I can only access this ... in http: // localhost . Is it possible? I want it to be if / var / www is the document root, and then if I go to localhost / app1, these requests should be redirected to localhost / app1 / public / index.php, and if I go to localhost / app2 these requests must be redirected to localhost / app2 / public / index.php.
Hope I explained it clearly, any help is appreciated.
In the end
I liked Phil's solution in the best way because I did not want to change the local hosts file and use the ServerName directive. This would be good in a production environment if you have a separate domain name for each application, but not for development.
In addition to this, I had a 403 forbidden issue when using an alternate directory to serve web content. As I said, perms seemed correct, the problem was in SE_Linux, and in the security context of files that were not installed on httpd_sys_content_t. I am posting this solution that I found here , as it relates specifically to this problem. Thanks.