Skip to content

Instantly share code, notes, and snippets.

@mdpuma
Created May 4, 2016 15:34
Show Gist options
  • Select an option

  • Save mdpuma/e246f7cbc37fa628def9e618525006f9 to your computer and use it in GitHub Desktop.

Select an option

Save mdpuma/e246f7cbc37fa628def9e618525006f9 to your computer and use it in GitHub Desktop.
Apache memory leak mod_rewrite recursion
# ISSUE:
# Example of bad rewrite rule
# first, check if url is not file or directory, if not then do rewrite!
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule "^(\S*)\s+(\S*\s.*)$" $1-$2 [N]
# if is set N flag, do this rewrite indefinitely (limited to 32000 iterations in apache >= 2.4.8)
################################
# FIX:
# decrease limit 32000 if is needed
# file modules/mappers/mod_rewrite.c
# 239 line:
#ifndef REWRITE_MAX_ROUNDS
#define REWRITE_MAX_ROUNDS 32000
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment