Tamás Pap
Tamás Pap

Reputation: 18283

Redirect a subdomain to another but don't change the address bar

I want to redirect subdomain1.domain.com to subdomain2.domain.com but without changing the addres in the address bar.

Is this possible via .htaccess? If not, what will be an alternative solution (I'm using cPanel)?

I don't want to use a proxy ([P])!!!

Upvotes: 0

Views: 369

Answers (1)

Jon Lin
Jon Lin

Reputation: 143906

Unless the 2 subdomains share a document root (or one is in a subdirectory of the other), then you can't do it without a proxy of any kind, with a [P] in htaccess or setting up a reverse proxy using ProxyPass (note that both use mod_proxy). There's no alternative solution that's strictly apache. You could write a script to load the pages of the other subdomain and park it on the first subdomain, but that's proxying as well, you're better off just using mod_proxy or one of it's extensions (like mod_proxy_html), which handles internal url rewrites of redirect locations, and cookies. An example of a non-apache solution would be mounting one subdomain's document root into the other and using mod_rewrite.

Upvotes: 1

Related Questions