Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want staging.mywebsite.com to point to the staging virtual host, for the live I want mywebsite.com and www.mywebsite.com to point to the live one etc., and then for *(everythingelse).mywebsite.com needs to point to the development server.

Anyone have any idea?! I posted a couple times on StackOverflow to no avail.

EDIT: I only have 1 server! Just to be clear. I can purchase 2 more IP's if necessary however.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

First set your DNS so that you have an A record for "" (blank), "www" and "staging" which point to the live server's IP address. Next, set another A record for "*" (ask your provider how to do a wildcard if that doesn't work) pointing to your development server.

Next, in your Apache configuration on the live server, put a ServerName of mywebsite.com with ServerAlias www.mywebsite.com pointing to the live DocumentRoot, and put a second VirtualHost in place with the ServerName staging.mywebsite.com.

Finally, on your development server, put the ServerName to be whatever you want (eg. example.mywebsite.com) and the ServerAlias to *.mywebsite.com" - you could also just use the default DocumentRoot if you want it to match anything that ends up at that server.

share|improve this answer
    
Do we need multiple IP addresses? Is there anyway to do all of this on one IP? –  Walker Aug 11 '10 at 14:41
    
From you question it sounded as though you had at least two servers. You can do all of this on one IP address providing you don't have more than one SSL certificate. –  James Lawrie Aug 11 '10 at 15:29
    
Sorry about that, I made an edit to the original question. I can purchase more IP's (I'm on RackspaceCloud) to run the dev / staging server if necessary - or, how would you solve the problem with one IP? –  Walker Aug 11 '10 at 15:38
    
Just wildcard your DNS so that everything on that domain points to your server, then use Apache NameVirtualHosts to split the requests. –  James Lawrie Aug 11 '10 at 15:40
    
Thanks for the help, we're trying to work it out now! –  Walker Aug 11 '10 at 18:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.