Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule: cannot compile regular expression

         

webvivre

11:36 am on Dec 21, 2009 (gmt 0)

10+ Year Member



Error message: RewriteRule: cannot compile regular expression:
'^([[:punct:]/:\\-\\'(){}.&=_a-zA-Z0-9\\]*)/([[:punct:]/:\\-\\'(){}.&=_a-zA-Z0-9\\]*)'

Has been working fine but seems to have happened when gzip compression was enabled on the server

Here is the .htaccess file:
AddType application/x-httpd-php .php .htm .html

RewriteEngine On
RewriteRule ^([[:punct:]/:\-\'(){}.&=_a-zA-Z0-9\]*)/([[:punct:]/:\-\'(){}.&=_a-zA-Z0-9\]*) /community/articles/buying.php?cat=$1&ref=$2 [L]
RewriteRule ^([[:punct:]/:\-\'(){}.&=_a-zA-Z0-9\]*)/([0-9]*)/ /community/articles/article.php?title=$1&id=$2 [L]

Any ideas please?

g1smd

1:14 pm on Dec 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'll guess that the backslash needs to be escaped.

I have no idea what [:punct:] is supposed to do.

Certainly the nested [[ ]] will be a problem.

webvivre

2:04 pm on Dec 21, 2009 (gmt 0)

10+ Year Member



Sorry - perhaps you can explain; how do you escape the backslash?
How to get rid of nested [[]] ?

jdMorgan

5:10 pm on Dec 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks to me like you're trying to use 'fancy' regular expressions as allowed in some advanced scripting languages. Such constructs as "[:punct:]" are not supported by mod_rewrite. You'll need to re-code the patterns to explicitly state the characters you wish to accept -- or alternatively, code them to state the characters you wish to reject using a negative-group match (using [^a-z] versus [a-z], as a simplistic example)

See the mod_rewrite documentation and the regex tutorial cited in our Apache Forum Charter for more information on patterns and escaping rules (which differ inside and outside of alternate-character [groups]).

Jim