Why Setup Virtual Host:

Setting up a virtual host allows you to use an alias name for your localhost. We can setup multiple vhost as per our need so that each local website can be accessible through specific name.

let’s say your site resides in “http://localhost/site1” and you want to load all the assets. There is always an issue when we follow traditional step like creating a folder inside “..\xampp\htdocs\site1”. This is the place where we used to place our hosting site in Windows, and always get an issue when they want to fetch any file resides in those directory.

In this case, URL becomes “http://localhost:8012/site1/sites/default/files/image.jpg”. Due to an invalid path, files become inaccessible and as a result, they won’t get loaded in the page.

Steps for creating Virtual Host

Step 1:

Open httpd.conf file present in C:\xampp\apache\conf\httpd.conf
Remove the #(hash) sign present to include the “httpd-vhosts.conf” file in httpd.conf file.

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf


# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Step 2:

Create a virtualhost file. Open “httpd-vhosts.conf” file. And copy the below lines of code.

<VirtualHost *:80>
ServerAdmin webmaster@localhost.com
ServerName <SERVER_NAME like local.pos.com>

Replace PATH_TO_PROJECT_DIRECTORY_HERE & SERVER_NAME with appropriate values, Save the file.


Open C:\Windows\System32\drivers\etc\hosts

Add the below line at the end of file.      <SERVER_NAME like local.pos.com>

Restart apache server and visit the site URL.

That’s all is needed to set up a virtual host.

Categories: hosting


Wordpress Voice Comments · April 7, 2018 at 10:18 AM

Grow your online community with voice comments. Let your readers voice their opinions in a fun, fast and easy way. Improve your user retention, website SEO, and get more conversions. Get the Free Plugin here, http://bit.ly/-Voice-Comments

ants control service · June 14, 2018 at 6:44 PM

Thanks for the helpful write-up. It is also my opinion that mesothelioma cancer has an incredibly long latency period of time, which means that warning signs of the disease may well not emerge until finally 30 to 50 years after the 1st exposure to asbestos. Pleural mesothelioma, which can be the most common kind and influences the area within the lungs, will cause shortness of breath, upper body pains, plus a persistent cough, which may bring about coughing up body.

Leave a Reply

Your email address will not be published. Required fields are marked *