0

Apache virtual hosting url redirect from one domain to other domain without showing the url in the browser?

Cœur
  • 37,241
  • 25
  • 195
  • 267
vivek sharma
  • 17
  • 1
  • 9

2 Answers2

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