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 would like to know how to configure my VPS so that it's only accessible using sub.domain.com, and not domain.com. Anyone know how to do this?

share|improve this question

2 Answers 2

Point the domain.com A record else where and the www. at your servers IP address.

A better option would be to 301 redirect the domain.com to the sub.domain.com so if a user types in domain.com it shows as sub.domain.com

share|improve this answer
the reason I'm doing this is so that clients who I build sites for cannot see the sites until they are final. therefore, I cannot have domain.com simply redirect to sub.domain.com - i need domain.com to show a 'page not found', while i test using something like test.domain.com –  Cooper Maruyama Nov 2 '12 at 19:27

SImple: do not define an IP address for domain.com, only one for sub.domain.com.

share|improve this answer
this didnt work - i think vhost config needs to be adjusted. I tried changing ServerName domain.com to ServerName sub.domain.com which also did not work. –  Cooper Maruyama Nov 2 '12 at 21:37
It does work. You also need to change the ServerName but the right thing to do is to have no address record for domain.com in the DNS. So, two things to adjust. –  bortzmeyer Nov 2 '12 at 21:59

Your Answer


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.