homepage Welcome to WebmasterWorld Guest from 23.23.22.200
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

    
Host file
sub domain test site
glimbeek




msg:4146183
 10:21 am on Jun 3, 2010 (gmt 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]

 

lammert




msg:4146905
 1:39 pm on Jun 4, 2010 (gmt 0)

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.

glimbeek




msg:4147996
 7:16 am on Jun 7, 2010 (gmt 0)

Yeah that's what I thought...

Cheers for the reply :)

Jonesy




msg:4150905
 1:54 am on Jun 11, 2010 (gmt 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.

phranque




msg:4151052
 7:38 am on Jun 11, 2010 (gmt 0)

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...]

glimbeek




msg:4151067
 8:24 am on Jun 11, 2010 (gmt 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? :)

lammert




msg:4151701
 4:30 pm on Jun 12, 2010 (gmt 0)

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.

glimbeek




msg:4152208
 6:46 am on Jun 14, 2010 (gmt 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.

youfoundjake




msg:4152220
 7:15 am on Jun 14, 2010 (gmt 0)

Maybe JDMorgan or g1smd can chime in, what about rewrites based on your ip address?

phranque




msg:4152228
 8:01 am on Jun 14, 2010 (gmt 0)

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.

youfoundjake




msg:4152386
 3:42 pm on Jun 14, 2010 (gmt 0)

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.

phranque




msg:4152585
 9:55 pm on Jun 14, 2010 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved