0

I want to make a rewrite that under the url www.example.com will be site example2.com/www but I want it not to change the url in browser to example2.com/www/.

So after entering in browser http://www.example.com I will see site under http://example2.com/www but in browser it still be http://www.example.com

I tried something like:

 RewriteRule (.*) http://example.com/www [L]

I put this in virtualhost config of www.example.com it works but with changing url.

Is there any different way to rewrite http and https in this manner?

EDIT... I'm using LiteSpeedBalancer and www.example.com is virtualhost only to show example.com/www (So no contest is under www.example.com this domain is only to rewrite to example.com/www)

It's complicated and at first I made example with www.example.com rewriting to example2.com/www to point that those are different virtualhosts.

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
B14D3
  • 5,188
  • 15
  • 64
  • 83
  • So you want to display some other web site's content as if it were your own? I don't think so. – Michael Hampton Aug 17 '12 at 05:45
  • Both this website are on my server ... and to be honest it wasn't my idea (but developers :/) and I made example2 only to be clear that this are two websites. I will change this – B14D3 Aug 17 '12 at 06:00
  • Perhaps you should also explain what it is the developers are really trying to do, so we can tell you exactly why it's impossible. :) – Michael Hampton Aug 17 '12 at 06:05
  • What's wrong with `ServerAlias`? Or does it need to have an HTTP host header that includes the `www`? – Shane Madden Aug 17 '12 at 06:09

2 Answers2

0

A workaround is to use frame forwarding in your control panel.

Paddington
  • 373
  • 5
  • 17
0

It is possible to achieve what you describe with mod_proxy but as others have commented you need to ask yourself "Why?". This would be a whole lot simpler to virtual host on example2.com

In any case, you will need the mod_proxy mod_proxy_http and possibly mod_proxy_html modules loaded

Then something like this in your Apache config

# turn the general proxy off
ProxyRequests Off

# pass requests for / to the backend /www
ProxyPass / http://example2.com/www

# fix and redirect headers from the back end
ProxyPassReverse / http://example2.com/www

# fix any domains in cookies from the backend to the frontend.
ProxyPassReverseCookieDomain example2.com example.com

# fix any cookie paths form /www to the front end /
ProxyPassReverseCookiePath / /www

Then if the html on the backend site still manages to bring back the /www then you can open your can of worms, load mod_proxy_html and try:

ProxyHTMLEnable On
ProxyHTMLURLMap /www /

There's a lot more you can do with mod_proxy_html in the config guide

Matt
  • 1,559
  • 8
  • 11