httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen Boyle <...@bourse.ch>
Subject Re: Web Redirection
Date Fri, 19 Apr 2002 11:00:19 GMT
Diye Wariebi wrote:
> 
> I am trying to redirect a site as below
> 
> When you type in http://www.domain.com I want the user to be redirected
> to http://www.new-site.com but I want their browser to still show
> http://www.domain.com
> 
> I am doing this using rewriterule in the virtual host section as below
> 
> RewriteEngine on
> RewriteRule /(.*) http://www.new-site.com/$1 [R]
> 
> The redirection is working but I cannot keep the original URL showing.
> 
> Can anyone help please?  Is this possible?

Think about it. Re-direct means to send someone to another site. To do
this, you have to tell the browser the URL of the new site and so it
will display it. What happens is:

Client: http://www.domain.com
Server: 301 -> http://www.new-site.com
Client: Ok, http://www.new-site.com (changes URL in location window)

This is different from rewriting which is used *within* one site and
allows you to serve up page XYZ when the user requests page ABC. This is
hidden from the user (i.e. the browser doesn't change) because the
swapping is happening on the server-side and so the client is unaware of
it. e.g. 

RewriteRule /banana.html /kiwi.html

Client: http://www.domain.com/banana.html
Server: he asked for banana.html, I'll send him kiwi.html
Client: displays page (still thinks it's called banana.html)

Confusingly, RewriteRule allows you to do plain rewrites like ABC -> XYZ
*and* real redirects (using the [R] flag as you have done above). Note
that anytime you change hosts, you cause a redirect so it is not
possible hide a change of hosts from the client. This is true even if
domain and new-site are on the same server.

It occurs to me that there is a hacky way you could emulate this *if*
both sites were on the same server - you'd have to place the content of
new-site under domain's document root then rewrite requests for pages
under domain into requests for new-site pages... bit messy and not
really what you want.

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message