# 2010-07-20 Apache Rewrite Loops

Last edit

Summary: fixing UseMod markup

Changed:

< : Request exceeded the limit of 10

to

> [quote]
> Request exceeded the limit of 10

> [/quote]

Changed:

< : In order to prevent endless loops of internal redirects issued by per-directory !RewriteRules, mod_rewrite aborts the request after reaching a maximum number of such redirects and responds with an 500 Internal Server Error. [http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriteoptions]

to

> [quote]
> In order to prevent endless loops of internal redirects issued by per-directory !RewriteRules, mod_rewrite aborts the request after reaching a maximum number of such redirects and responds with an 500 Internal Server Error. [http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriteoptions]
> [/quote
]

Changed:

< : Note: RFC 1945 and RFC 2068 specify that the client is not allowed

to

> [quote]
> Note: RFC 1945 and RFC 2068 specify that the client is not allowed

> [/quote]

My Apache error.log file for emacswiki.org is full of the following:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘!LimitInternalRecursion’ to increase the limit if necessary. Use ‘!LogLevel debug’ to get a backtrace.

In addition to that, 0.35% of my access.log entries (263/74905 in the current log file) seem to result in an internal server error – which is exactly what the Apache documentation says:

In order to prevent endless loops of internal redirects issued by per-directory !RewriteRules, mod_rewrite aborts the request after reaching a maximum number of such redirects and responds with an 500 Internal Server Error. [1]

I checked the two big .htaccess files (one for cgi-bin, another one for htdocs) and all the !RewriteRule entries have the [L] or [last] flag. [2]

How can I debug this? This is a shared hosting environment. I cannot use !LogLevel.

Apparently ordinary users are running into the same problem. DrewAdams is reporting that every now and then when he’s saving a page, he gets the internal server error. Saving involves a POST request with a redirecting reply – code 302. This is theoretically non-standard but widely used:

Note: RFC 1945 and RFC 2068 specify that the client is not allowed to change the method on the redirected request. However, most existing user agent implementations treat 302 as if it were a 303 response, performing a GET on the Location field-value regardless of the original request method. – RFC 2616, section 10.3.3 “302 Found”

Want to take a look?

Tags:

Last edit

Summary: Rewrite works somewhat differently in .htaccess files; see the more recent doc for [Last] at . . .

No diff available.

Rewrite works somewhat differently in .htaccess files; see the more recent doc for [Last] at http://httpd.apache.org/docs/trunk/rewrite/flags.html#flag_l for some warnings.

– Dan Poirier 2010-07-23 00:55 UTC

Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.