Is there a way to add a masked redirect to another domain?

Hey folks,

I am trying to add a root redirect for one of the virtual servers (domains) i serve to an existing website but i want to keep the later domain in the url (masking).

I have tried DNS CNAME which i know it can not mask, and website redirect (Regexp URL redirects) which also does not mask.

Then i used “Map remote Location: headers to local” as local i tried both “/” and the full path to the public_html but no redirect happened. they proxy module is loaded, on (uncommented the respective lines in httpd.conf) and allowed proxy access to the server ip (also tried localhost).

Really is there a way to achieve this? There is a masking redirect option in my domain registrar but i want to control this from virtualmin. I want the user to type www.domain1.com and see the contents of www.domain2.com while the address bar still says www.domain1.com

any tips?

Generally, you would not want the browser to show a different URL than the user typed in, for security reasons.

Your aim can still be achieved using Apache’s reverse proxy feature. Using that, Apache will fetch the destination page for the user and forward it. But you should consider why you need/want that function.

Ok i made some improvements. I used the following on my virtual host apache config

<Location / >
ProxyPass http://domain2.com
ProxyPassReverse http://domain2.com


and now domain1 shows the contents (masked! yes this works!) of the resolved domain2 website which is not what i want. It resolves domain2.com to its responding IP address and fetches http://IP:80 which is another website not the one i want as that server serves multiple virtual hosts too.

The reason i want to do this is because that person wants to change his domain name for that website (in my efforts just adding a domain name with masking can make it look like primary domain) without changing his current host which he cannot do through his cPanel because of low permissions (i guess you get what you pay for).

Has anyone ever done this? Should i abandon the whole apache configuration and just put an index.html which iframes his whole website?

Can you explain “change the domain name without changing the current host”? Can’t he just use the new domain name instead of the old one if he wants to change it?

Also, can you explain the problem with the “resolved IP”? I didn’t understand that…

Generally, a redirect should be transparent to the user. I personally don’t like “masquerading” things like that, whether it’s via reverse proxy or via iframes. i.e. I want to see in the browser line what URL I’m actually fetching. If the users are to use a new domain name from now on, a redirect is the best way to go. There should be a pressing technical reason if you wish to “mask” an URL.

We have no permissions on his hosts to change the domain name of his hosting package. It’s either we mask the url to the new domain or he buys another hosting package and moves his website over which is what i’m trying to avoid.

So the server where his website is hosted uses cPanel and serves many websites. Using DNS and apache virtual hosts (same principle with virtualmin) he redirects each request to the corresponding web page. On http://server-ip there is a web page (server dummy page actually) which is irrelevant but my Reverse Proxy trick fetches that website instead of the http://domain2.com

Actually the reverse proxy should fetch the correct page, provided your URL is complete correct, just like a browser does. I’m a bit stumped right now why it should fetch the default page instead.

Also note that the reverse proxy trick does not work in all cases, or might need additional configuration in web software that’s potentially installed on the domain. Such software might generate URLs itself, thus showing the user links to the “unwanted” domain.