1

I recently set up monitoring for my mod_rewrite server with help in the question Pattern matching across multiple lines.

Every once in a while - I'm not sure what triggers it - I get a HTTP/1.1 301 OK instead of a HTTP/1.1 301 Moved Permanently. Why?

This is currently causing my scripts to create a false positive. The rewrites are of the following form.

RewriteRule ^ http://www.mydomain.org%{REQUEST_URI} [R=301,L]

The rewrite rule is still working and I still eventually get a 200 code back from www.mydomain.org.

I can update the regular expressions to match on a 301 OK but I'd really like to know why it would change.

I'm running the latest release of CentOS 5 on the server if it matters.

Tim Brigham
  • 1,017
  • 1
    Correct me if I'm wrong but HTTP 301 = Moved Permanently. http://en.wikipedia.org/wiki/HTTP_301. What's the problem? – Braiam Dec 03 '13 at 14:32
  • @Braiam I get a HTTP/1.1 301 OK – Tim Brigham Dec 03 '13 at 14:55
  • Yeah, HTTP/1.1 301 means Moved Permanently. There isn't anything weird. 301 = Moved Permanently = HTTP/1.1 301 = HTTP/1.1 301 Moved Permanently. IMHO HTTP servers only returns the number of the message not the meaning. – Braiam Dec 03 '13 at 15:02

3 Answers3

1

The problem you have may be dued to the implementation of the 'reason phrases' included in PHP or Apache.

According to what I know, you may have different 'reason phrases' regarding the php version you are using. fcgid or php-cgi can have different reason phrases implemented than the one implemented by Apache.

You may also have a php header function changing that reason phrase somewhere in your fronts, and you may not have seen it if you have many, and if you use load balacing (this could explain the reason why it doesn't return the wron reason phrase all the time).

The most important in your case is to have proper return code : 301. If I were you, I would modify my monitoring check so that to deal with the response code returned, and not the reason phrase returned.

My2cents

rustx
  • 21
0

The http status line consists of two parts: a number and a message. the number is for the machine to use, the message for people when debugging. the number is the important part. the message can and will vary by language, server, script, etc. mod rewrite sets the message to OK with a successful rewrite. This is fine. determine your action based on the number.

hildred
  • 5,829
  • 3
  • 31
  • 43
0

Your fine. It could say "301 Pickles" and still be fine. The only action taken by any client should be on the number code.

Usually your accept header or content header will change the human readable phrase. I have seen some servers return "301 OK" when they can't determine acceptable content to send back. It's a bit odd seeing as the response header isn't part of the content, but I have seen them do it anyway.

In short, your response code is fine so long as it's a 301 the words after it don't matter one bit. To implement a proper check your scripts should key off the number. The words are arbitrary.

coteyr
  • 4,310