Apache virtual hosting url redirect from one domain to other domain without showing the url in the browser?
Asked
Active
Viewed 216 times
0
-
Full window size iframe. Otherwise you could ajax-fetch a page from the other server but that is not a redirect. – Dave S Jun 20 '17 at 20:39
-
No, I have need to redirect from abc.com/new to xyz.com without using ajax or iframe. – vivek sharma Jun 20 '17 at 20:42
-
1Browsers won't let you do that. They don't want to let site xyz impersonate site abc. – Dave S Jun 20 '17 at 20:44
2 Answers
0
That's not redirect, that's called Reverse Proxy.
Example:
ProxyPass /url-path/ http://backend.example.com/url-path/
This will reverse proxy all requests to /url-path/whatever to the server backend specified
More information at:
http://httpd.apache.org/docs/2.4/mod/mod_proxy.html
http://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

Daniel Ferradal
- 2,727
- 1
- 13
- 19
0
No, there isn't a way to do this with .htaccess if your sites are on different servers. Doing so would present big security hole, imagine if someone does this with a bank´s website.
However, if both are hosted on the same server try this on your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^http://www.domain1.com$
RewriteRule (.*)$ http://www.domain2.com$1 [P]
</IfModule>
If you own both domains you could accomplish this with domain name forwarding. Check the options in your registrar (maybe godaddy, or dns managers like cloudflare).

Daniel Bernardez
- 123
- 1
- 6