如何在Apache2中像tomcat中那样部署两个基于zend框架的应用程序

我有两个叫做financefleet Zend框架应用程序。 它们都具有相同的.htaccess文件,如下所示

 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] 

我创build了两个名为fleet.localfinance.local虚拟主机。 这是我的fleet.local文件:

 # APACHE CONFIGURATION FOR THE fleet.local APPLICATION <VirtualHost *:80> ServerName fleet.local DocumentRoot /home/user/fleet/public SetEnv APPLICATION_ENV dev <Directory /home/user/fleet/public> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> DeflateCompressionLevel 9 

这是我的finance.local文件:

 # APACHE CONFIGURATION FOR THE fincance.local APPLICATION <VirtualHost *:80> ServerName fincance.local DocumentRoot /home/user/fincance/public SetEnv APPLICATION_ENV dev <Directory /home/user/fincance/public> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> DeflateCompressionLevel 9 

当我想要使用财务,我会说http://finance.local ,当我想要使用舰队,我会说http://fleet.local

现在我想要做的只有一个名为companyX.local虚拟主机,如果我想要财务应用程序,我只http://companyX.local/fleet为我的车队inputhttp://companyX.local/financehttp://companyX.local/fleet应用。 我怎么去做这个?

得到它了!!!

 <VirtualHost *:80> ServerName companyX.local Alias /finance "/home/user/finance/public" <Directory /home/user/finance/public> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> Alias /fleet "/home/user/fleet/public" <Directory /home/user/fleet/public> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> 

并改变了这样的财务重写基础:

 RewriteEngine On RewriteBase /finance RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] 

并改变了这个舰队的改写基地:

 RewriteEngine On RewriteBase /fleet RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] 

试试这个 – 它甚至不需要RewriteBase,并且可以在root或者subdir中工作。

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ RewriteRule ^(.*)$ - [E=BASE:%1] RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]