mod_rewrite incorrectly escaping characters
tried to find the problem for this but nothings really working.
Basically, I'm trying to use the following regular expression:
RewriteRule ^course/filter:([a-zA-Z0-9_-\,\=]+)$ php/manage_courses.php?display=list&filter=$1 [L]
however I get a 500 error and this in the error log (note the escaped chars):
[Wed Jan 27 16:29:31 2010] [alert] [client ::1] H:/SVN/prj_us/.htaccess: RewriteRule: cannot compile regular expression '^course/filter:([a-zA-Z0-9_-\\,\\=]+)$', referer: http://localhost/~svn/prj_us/php/admin_index.php
It seems to be automatically escaping the \ char, which it shouldn't be doing... I have tried swapping the order of the regexp code, as well as removing the \ altogether but its not working.
Any suggestions? Cheers for your help.
notes: - works without the "\,\=" part, but i need those two chars in particular for the URL that I am trying to rewrite. - all other regexps in the .htaccess file work, although they dont have 开发者_开发技巧the two chars as above.
You shouldn't need to escape anything except the -
character in your character class. Try this:
[-a-zA-Z0-9_,=]
Neither ,
nor =
is special in a range, but -
is. Move the -
to the beginning, and remove the backslashes.
精彩评论