Hosts file

Hi I like to use the hosts file on my windows 7 to set up new projects to redirect to my own computer and thus i can set up wordpress to immediately use the correct domain, saving me some trouble later on. however from time to time i would still need to refer to the proper website which is online, is there any way i can still have access to the online site without having to edit the hosts file each time. The only idea i have right now is to have a virtual machine but im hoping there is something even easier

That isn’t going to work when WordPress applies its automatic redirect to the domain on the live server.

The only way around it is to update the two fields in the database that identify the domain info on the local copy of the site to match to whatever domain name you are referencing the local copy with - then you don’t even need the hosts entry as you can just reference the appropriate folder within localhost.

That of course means you’d have to update those entries in the database again every time you copy the database across.

At least updating the database only needs to be done when you copy it between the two locations and doesn’t require a reboot in order to pick up the change.

ok, so i guess ill have to go with the virtual machine for this, thanks



Create your localhost VirtualHosts NOT using the online domain name (with the tld). That way, your hosts file will ONLY control the localhost VirtualHosts and your ISP’s DNS will maintain the online hosts. For example, my domains and would be dk locally (acronym or tld-less domain name on the localhost).

It works for me!