Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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 5: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 6: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 6: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 6:09

2 Answers 2

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

share|improve this answer

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

share|improve this answer
    
could you expand your answer for more details –  B14D3 Aug 17 '12 at 7:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.