You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Diye Wariebi <di...@escapethenet.co.uk> on 2002/04/19 12:33:12 UTC

Web Redirection

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?

-- 
Diye



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


Re: Web Redirection

Posted by Diye Wariebi <di...@escapethenet.co.uk>.
Thanks Guys

I do have mod_proxy enabled and I tried using the [P] options within the
Rewriterule and it works fine.

FYI

The site second site is on a second server.

On Fri, 2002-04-19 at 12:18, Owen Boyle wrote:
> James Tait wrote:
> > 
> > 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
> > 
> > Surely you can proxy the request?
> > 
> > RewriteEngine on
> > RewriteRule /(.*) http://www.new-site.com/$1 [P]
> > 
> > This assumes, of course, that mod_proxy is enabled.
> 
> Yep - that'll work... I always forget about mod_proxy! The poster should
> be aware however that all proxied traffic will have to pass through his
> server - but that's his lookout...
> 
> 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
> 
> 
-- 
Diye



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


Re: Web Redirection

Posted by Owen Boyle <ob...@bourse.ch>.
James Tait wrote:
> 
> 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
> 
> Surely you can proxy the request?
> 
> RewriteEngine on
> RewriteRule /(.*) http://www.new-site.com/$1 [P]
> 
> This assumes, of course, that mod_proxy is enabled.

Yep - that'll work... I always forget about mod_proxy! The poster should
be aware however that all proxied traffic will have to pass through his
server - but that's his lookout...

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


Re: Web Redirection

Posted by James Tait <JT...@wyrddreams.demon.co.uk>.
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
>>

Owen Boyle wrote:
> It occurs to me that there is a hacky way you could emulate this *if*
> both sites were on the same server 

Surely you can proxy the request?

RewriteEngine on
RewriteRule /(.*) http://www.new-site.com/$1 [P]

This assumes, of course, that mod_proxy is enabled.

--
+------------------------------------+------------------------------------+
| James Tait                         | ICQ# 17834893                      |
| MUD programmer and Linux advocate  | http://www.wyrddreams.demon.co.uk/ |
+------------------------------------+------------------------------------+


________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

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


Re: Web Redirection

Posted by Owen Boyle <ob...@bourse.ch>.
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