In my development machine i wanted to have a specific vHost for each project. Something that would allow me to type URL like:
I started to set for each one a vHost in Apache but after a while I’ve found myself with too many vHost files.
So I started to search for a more easy and fast way, and here it is:
Note: you need to install Apache mod_rewrite to make things work.
Preamble:
Let’s say we want to install a test/demo version of Wordpress and access it from the URL http://wp-test.lan/
hpatoio@namazu:~$ sudo su -
[sudo] password for hpatoio:
root@namazu:~#echo “127.0.0.1 wp-test.lan” >> /etc/hosts
root@namazu:~#exit
hpatoio@namazu:~$RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.lan$
RewriteRule ^(.+)$ /%1$1 Basically :
hpatoio@namazu:~$sudo /etc/init.d/apache2 restart
Now if open your browser and you point it to the URL http://wp-test.lan/ you should see the WP installation page. Right ?
Override default directory index in Apache.
Open .htaccess
DirectoryIndex home.php index.php