Re: Redirection using .htaccess



On Sun, 05 Mar 2006 07:20:29 -0700, hug
<contact_info@xxxxxxxxxxxxxxxx> wrote:

|nomail@xxxxxxxxxxxx wrote:
|
|>On Sat, 04 Mar 2006 07:52:07 -0700, hug
|><contact_info@xxxxxxxxxxxxxxxx> wrote:
|>
|>|"Vijay Manda" <vijaykillu@xxxxxxxxx> wrote:
|>|
|>|>I am using .htaccess to redirect a dynamic url, but the url in the
|>|>address bar of the browser is getting changed to the new url. Is it
|>|>possible that I retain the same old url in the address bar with the
|>|>page getting redirected?
|>|
|>|If a browser redirect is involved, what the browser chooses to display
|>|is out of your control. The only way to ensure that there's only one
|>|url involved is to deliver the content in response to a get for that
|>|url.
|>|
|>|It is certainly possible to intercept a get for a "virtual" url and
|>|supply the content (via your 404 exit) and in that situation there
|>|would be no redirect involved and the browser would have to make up
|>|its own url if it was going to display something else in the address
|>|bar.
|>|
|>|I hope I haven't misunderstood your question; best luck.
|>
|>To stop the URL in the address bar from changing do not set the R flag
|>
|>For example
|>
|>RewriteRule ^string_to_look_for.html$ /actual_page.html [R,L]
|>RewriteRule ^string_to_look_for.html$ /actual_page.html [L]
|>
|>The first example will change the URL in the address bar, the second
|>won't.
|>
|>I use this on my site a lot
|>Steve
|>http://www.oast.com/
|
|That's interesting. I'm not an .htaccess guru yet, I tend to use code
|that I can test.

I test this sort of thing on my home dev box, or in a non public
section of a live web site.

|Based on the [flag] syntax shown here,
|http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteRule it
|appears that the "R" flag forces an "external redirection", and the
|"L" flag just means to ignore further rules after changing the name of
|the file to be fetched.

I make a practice of using the "L" flag to prevent unexpected
redirects.

|Iow the first performs a browser-redirect

That's correct

|the second just changes the name of the file to be fetched.

I think that is what the original poster wanted?

| Different methods of feline epidermal removal. <g>

:)

Steve
http://www.oast.com
.



Relevant Pages