Forum Moderators: phranque

Message Too Old, No Replies

doubt in redirection - how to keep the original url

doubt in redirecting the url in httpd.conf

         

itsraghz

12:36 pm on Nov 18, 2007 (gmt 0)

10+ Year Member



Hello Friends,

I have a doubt in redirecting the URL. I wrote a RewriteRule in the httpd.conf file with the parameters [R=301,L]. It is working as expected. But the redirected URL is getting changed in the browser's address bar.

How to keep the same/entered URL during redirection? Is that possible first of all? If that can be achieved and NOT called as redirection, how can we go about?

Thanks in advance.

Raghavan alias Saravanan M.

jdMorgan

3:01 pm on Nov 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An external redirect, by definition, changes the browser address bar.

What you're looking for is an internal rewrite, not an external redirect.

The two forms are:


# External redirect
RewriteRule ^foo\.html$ http://www.example.com/bar.html [R=301,L]
#
# Internal rewrite
RewriteRule ^foo\.html$ /bar.html [L]

The external redirect is a URL-to-URL translation, while the internal rewrite is a URL-to-server-filename translation.

Jim

itsraghz

3:26 pm on Nov 18, 2007 (gmt 0)

10+ Year Member



Thank you jdMorgan. I got it now.

But what if i have to keep the url but do a redirection. Its because i need to do this in our production HTTP Server but the request has to go to our Test environment.

Any other possibilities i can achieve OR no way at all?

jdMorgan

3:34 pm on Nov 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See Apache mod_proxy. You may want to reverse-proxy those specific requests from the production to the test server.

Jim