We're a bit green when it comes to this stuff and don't fully understand the answers found (we might also be using the wrong search terms).


We need to redirect a subdomain to another domain but mask the redirected domain.

So that this redirect:

subdomain.domain.com –> domain.com

Shows in the browser URL bar as:


And obviously any pages show correctly as:


Is this possible?


Some answers we've found talk about URL re-writing and others talk about a proxy pass.


Redirects and masking with Apache

But we don't fully understand how to set those up - i.e. what exactly goes into each virtual host and a step by step?

Both domains will be hosted on the same server and we have access to the virtual hosts.

Any help or pointers in the right direction would be much appreciated.



  • Why treat it as a different domain when the stuff's all on the same server? Just have the virtualhost for the "redirecting" domain have a <Directory> block for the other domain's files? – Shane Madden Jul 7 '15 at 1:03
  • 1
    Not the answer to your question, rather a bypass - but if its all being done in Apache, you should just be able to add a line "ServerAlias x.y.z a.b.c ..." which lists all the alterative domains Apache will answer for without actually rewriting it. – davidgo Jul 7 '15 at 3:04

For security reasons, browsers won't let you spoof the URL shown in the address bar. So, if you need the bar to show "subdomain.domain.com", then the browser will need to be talking to a machine at the IP address returned by resolving "subdomain.domain.com".

If subdomain.domain.com and domain.com is being served on the same machine, then you could internally proxy requests from one to the other's server. You could even do this if the servers were on different (although hopefully "nearby") machines. However, the longer the path, the greater the performance penalty.

  • Thanks heaps, will look into the proxy option - I might have some questions though about how to set that up as I don't full understand what's going on there. Will read up though. Cheers Ben – CMSCSS Jul 7 '15 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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