Web Programming

Treating a Subdirectory Like a Web Root Directory in XAMPP

Case:

You have created a website called zabath, and able to access the website by going to http://localhost/zabath.

So, You would like to set it up so that you can point local browser to say, http://zabath, and have it treat the foobar directory like the web root directory.

 

Answer:

To get your browser to look for http://zabath on your local machine you’ll have to add this line to your host file

127.0.0.1 zabath

Then add a virtual host in your Apache http.conf file,

<VirtualHost *:80>
    DocumentRoot path/to/zabath
    ServerName zabath
</VirtualHost>

You may also have to add another virtual host

<VirtualHost *:80>
    DocumentRoot path/to
    ServerName localhost
ServerAlias 127.0.0.*
</VirtualHost>

Source: superuser.com

Leave a Reply