1

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


Problem

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:

subdomain.domain.com

And obviously any pages show correctly as:

subdomain.domain.com/page-name

Is this possible?


Research

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

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

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.

Cheers

Ben

CMSCSS
  • 113
  • 1
  • 5
  • 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 `` block for the other domain's files? – Shane Madden Jul 07 '15 at 01: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 07 '15 at 03:04

1 Answers1

3

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.

Daniel Griscom
  • 493
  • 1
  • 4
  • 15
  • 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 07 '15 at 04:37