2

I have two Zend framework applications called finance and fleet. Both of them have the same .htaccess file as indicated below

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] 

I have created two virtual hosts called fleet.local and finance.local. This is my fleet.local file:

# 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 

And this is my finance.local file:

# 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 

When I want to use finance I will say http://finance.local and when I want to use fleet I will say http://fleet.local.

Now what I want to do is have a single virtual host called companyX.local and if I want the finance application, I will just type http://companyX.local/finance and http://companyX.local/fleet for my fleet application. How do I go about doing this?

1 Answer 1

1

Got it!!!

<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> 

and changed the rewrite base for finance like this:

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] 

and changed the rewrite base for fleet like this:

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] 

Try this — it doesn't even need RewriteBase and will work root relative or in a 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] 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.