How to allocate the given Url to a specific folder in my localhost in ubuntu 12.10?

81 Views Asked by At

I have two folder in my localhost var/www/project1 and var/www/project2

When I access one project url I want to get that site only how can I achieve that?

ex:

`project1.example.com` should go to the `project1/index.php`

`project2.example.com` should go to the `project2/index.php`

How can I achieve this? Is there any thing to change in apache or httpd.conf ?

Is there any redirection rules in apache or .htaccess

1

There are 1 best solutions below

4
arco444 On

Try:

DocumentRoot /var/www

RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$
  RewriteRule ^/(.*)$ /%1/$1

This would map project1.example.com/index.php to directory /var/www/project1/index.php

project2.example.com/index.php to directory /var/www/project2/index.php

project3.example.com/some/path/file.php to directory /var/www/project3/some/path/file.php....