Welcome to WebmasterWorld Guest from 54.144.7.239

Forum Moderators: phranque

Message Too Old, No Replies

Host file

sub domain test site

     
10:21 am on Jun 3, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 18, 2010
posts: 127
votes: 0


Hi,

I was wondering if the following is possible.

I have a website http://www.example.com
And I have a test site http://test.example.com

A lot of my scripts and solution use a absolute URL.
So for instance a lot (basically all) links on my site point towards http://www.example.com
This makes testing a annoying if not difficult task.

Both sites are running on the same IP
The test domain is a subdomain
The test site is installed in a folder called "test" which is in the public_html folder of the www (live) domain.
In the future we are looking into creating a "proper" development environment, but for now this will have to do.

Is there a way to "trick" my PC (using for instance the host file) to think that http://www.example.com is actually http://test.example.com? So I can test on my subdomain without having to change a lot of code etc to make it all work?

[edited by: phranque at 1:12 pm (utc) on Jun 3, 2010]
[edit reason] unlinked example.com subdomain [/edit]

1:39 pm on June 4, 2010 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2889
votes: 5


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.
7:16 am on June 7, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 18, 2010
posts: 127
votes: 0


Yeah that's what I thought...

Cheers for the reply :)
1:54 am on June 11, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 23, 2008
posts:143
votes: 0


I have a web site up on a host out there: www.example.net
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.

But,
    "A lot of my scripts and solution use a absolute URL.
    "So for instance a lot (basically all) links on my site point
    "towards http://www.example.com
    "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.
7:38 am on June 11, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10551
votes: 10


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:
[google.com...]
8:24 am on June 11, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 18, 2010
posts:127
votes: 0


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? :)
4:30 pm on June 12, 2010 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2889
votes: 5


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.
6:46 am on June 14, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 18, 2010
posts:127
votes: 0


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.
7:15 am on June 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 28, 2006
posts:1043
votes: 1


Maybe JDMorgan or g1smd can chime in, what about rewrites based on your ip address?
8:01 am on June 14, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10551
votes: 10


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.
3:42 pm on June 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 28, 2006
posts:1043
votes: 1


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.
9:55 pm on June 14, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10551
votes: 10


the external rewrite will work for any request using http protocol.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members