The hosts file maps domain names to IP addresses, not domain names to other domain names. In your case the test domain and the main domain are running on the same IP address which makes tricks with the hosts file to access temporarily your test domain as www.example.com impossible.
Yeah that's what I thought...
Cheers for the reply :)
I have a web site up on a host out there: www.example.net
I have apache running on this workstation, and have "www.example.tst"
in my hosts file on this workstation pointing to 127.0.0.1.
I have a (developing) copy of www.example.net hosted (internally)
on my workstation.
I browse to either www.example.net or www.example.tst , depending on
which one I wish to see.
Something like that works great for testing/developing.
Actually, I have that setup in place for 5 web sites.
"A lot of my scripts and solution use a absolute URL.
"So for instance a lot (basically all) links on my site point
"This makes testing a annoying if not difficult task.
--- bummer. You're trying to set up a 2nd kludge to get around the
headaches caused by the 1st kludge.
Bite the bullet and fix the original problem.
using absolute urls is not a kludge and there are valid reasons for using either absolute or relative urls.
for example, it is harder to plagiarize content that uses absolute urls.
for what it's worth, google suggests using absolute urls:
As phranque points out, using absolute URL's isn't a "problem".
We are doing our best to make sure we implement/use every SEO related tip or trick that's out there.
Thanks for the reply though!
For the future we are looking into a development environment.
Any suggestions? :)
The easiest development environment is the same setup as your server, but then on your local network or on your local PC. The test environment I am using is a virtual machine running on my laptop which contains the same operating system version and webserver setup as my public webserver. In my case the laptop runs Windows 7 and the virtual machine is Linux. If I want to test the website locally the virtual machine is fired up and a line is added to the hosts file which maps www.example.com temporarily to the local IP address of the virtual machine.
There are a number of situations where using a separate computer or a virtual machine are not necessary for a working test environment. Apache and MySQL are for example available in a Windows distribution, or your local computer may already run the same operating system as your webserver.
Thanks for the reply lammert.
We are looking into something like that. However we have more then 30 different websites on more then 30 different hosts with more then 30 different setups...
Not all these website need a testing environment, nor are they all as complicated to justify a testing environment that is 100% identical as the server they run on. However we have around 12~15 websites that do need a 100% identical testing environment. This is rather tricky though, because we don't have the in house (l)unix skills to set this all up/maintain this.
Maybe JDMorgan or g1smd can chime in, what about rewrites based on your ip address?
if you are using a dedicated/static IP address or you can specify a custom user agent string with a browser plugin or some other method of uniquely identifying your requests you can add a rewriterule that externally redirects all requests to the test subdomain.
Which is what I was thinking, but then it occured to me that the URL is hardcoded into the script, and I'm not sure if an external rewrite can work on a internal function.
the external rewrite will work for any request using http protocol.