I'm using mod_rewrite to rewrite URLs like this:
http://example.com/1,2,3,4/foo/
By doing this in .htaccess:
RewriteEngine On
RewriteRule ^([\d,]+)/foo/$ /foo.php?id=$1 [L,QSA]
It works fine, except for when "1,2,3,4" turns into a string longer than 255 characters, Apache returns a "403 Forbidden".
There is no problem visiting foo.php?id=1,2,3,4
directly, even with a very long id string, however this isn't an option for me.
Is there some Apache or other setting I should tweak?
UPDATE: I turned RewriteLog on with RewriteLogLevel 9. With a short id string, I get several lines in my log file. But when the id string is greater than 255 chars., nothing is logged (seems as though mod_rewrite isn't even executing?).
If you find this question interesting/helpful, please upvote it.
RewriteLog
andRewriteLogLevel
so you can see what is being matched and how it's really being rewritten. I would guess that only 255 characters are being copied into$1
, and that ends up being anid
that the client isn't authorized to see, so Apache returns the 403. I haven't looked at the code, but it could be that Apache manipulates the backreference in a fixed 256-byte buffer (the 256th is reserved for the terminating NULL).