Change my hosts file to route to a folder and not an ip

monkeymanbob picture monkeymanbob · Nov 28, 2013 · Viewed 15.9k times · Source

Fairly new freelance developer and I'm looking to add a local version of a website im working on for a dev environment.

I've got my localhost set up.

127.0.0.1 localhost

The syntax that I was using but is evidently not correct is

127.0.0.1/wordpress blahblahsite.ca

What route should I take to preserve my localhost, but have blahblahsite.ca route to my local folder and not the live site?

Answer

Asad Malik picture Asad Malik · Aug 3, 2015

Although its been couple of years since question was answered. My two pennies if any one stumble upon this question and really want to setup quickly without digging into documentation. Here goes: Enter this in to hosts file:

127.0.0.1 blahblahsite.ca

And in your apache folder, find httpd-vhosts.conf file. In a typical xampp installation on windows, you'll find here:

Drive:\xampp\apache\conf\extra\httpd-vhosts.conf

You should find couple or more eample virtual host setups commented out, just copy/paste or uncomment one of those and make changes as below:

<VirtualHost blahblahsite.ca:80>
    ServerAdmin [email protected]
    DocumentRoot "Drive:\xampp\htdocs\wordpress"
    ServerName blahblahsite.ca
    ServerAlias blahblahsite.ca
    ##ErrorLog "logs/blahblahsite.ca.log"
    ##CustomLog "logs/blahblahsite.ca.log" combined
</VirtualHost>

Remember to change: "Drive:\xampp\htdocs\wordpress" to your website files directory. Save files, restart xampp and now blahblahsite.ca should work from browser's address bar. Although steps are pretty easy and self explanatory, but do let me know if you have any questions or encounter and problems.