Forum Moderators: phranque

Message Too Old, No Replies

[R=301,L] not valid?

Apach 1.3 and 2.0 question.

         

g1smd

9:35 pm on Mar 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Elsewhere, I am told that [R=301,L] is not valid, and does not work, on Apache 1.3 and Apache 2.0.

Certainly, I can find little or no reference to using R=301 in the Apache 1.3 docs where most of the examples use simply [R,L] (which returns 302 status), but on the other hand I see plenty of examples of R=301 usage right here in this forum.

Could that be the beginnings of an urban legend, or have I missed something important here?

coopster

1:00 pm on Mar 28, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Misunderstanding of the documentation perhaps, which wouldn't be the first time. 302 status during redirect was common back then, and is still most prevalent today IMHO (think form processing). However, with the advances in search engine technology (think SEF urls), the 301 became the hot ticket.

I'm wondering if most confusion regarding the issue you raise here isn't in reference to the "L" requirement. For example, leaving it off. There is indeed an "invalid" reference in the latest Apache docs [httpd.apache.org] in that regard:

You will almost always want to use [R] in conjunction with [L] (that is, use [R,L]) because on its own, the [R] flag prepends [thishost[:thisport]...] to the URI, but then passes this on to the next rule in the ruleset, which can often result in 'Invalid URI in request' warnings.
(emphasis mine)

g1smd

1:31 pm on Mar 28, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Maybe. There are a number of places in the Apache mod_rewrite documentation where things aren't as clear as they could be, especially in the 1.3 set.

However this was a "do not use R=30x on Apache 1.3 or 2.0 you will get HTTP 500 error for any request" comment, and seemingly made with conviction.

coopster

1:33 pm on Mar 28, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Where did you see that? It has been quite clear in the docs since 1.3 that you can use HTTP response codes in the range 300 - 400 in a RewriteRule.

g1smd

1:38 pm on Mar 28, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's an ongoing conversation elsewhere where we are working on updating a large .htaccess file to fix syntax and logic errors.

Currently most of the redirects use [R,L] format.

I don't dispute that the other person saw the "Error 500" error message, but I don't think the R=301 in the code was the direct cause of that error.

coopster

5:11 pm on Mar 28, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I concur. Point them to the documentation [httpd.apache.org] again. The default status code is 302. Any status code in the 300 - 400 range can be used:

If no code is given a HTTP response of 302 (MOVED TEMPORARILY) is used. If you want to use other response codes in the range 300-400 just specify them as a number or use one of the following symbolic names: temp (default), permanent, seeother.


And, as you showed in your original syntax, follow redirection with the (L)ast rule flag too.