tags:

views:

64

answers:

1

Is it possible to do a mod_rewrite from one url to another without changing what appears in the address bar?

Example:

Source URL is http://domain1.com/news Target URL is http://domain2.com/news

I want to render pages from http://domain2.com/news/ but have http://domain1.com/news appear in the address bar.

Is this possible?

I've got this directive, but the URL in the address bar changes (which I don't want to happen):

RewriteRule ^(.*)$ http://domain2.com/news/ [L,NC]

A: 

As far as I know, it cannot be done with just a mod_rewrite rule that rewrites one domain to another. The http:// prefix causes an external redirect, which is why you see it in your browser. The server at domain1 sends the redirect back to the browser and the browser has to re-request from domain2. To avoid this, the server at domain1 has to be able to retrieve data from domain2. If you control both servers, I've heard you can use mod_proxy to accomplish this, but I don't know the details.

For rules that do not go from one domain to another, the normal behavior of mod_rewrite will not cause the browser to change the URL unless you use the [R] flag.

bmb