Welcome to WebmasterWorld Guest from 54.166.114.43

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

PCRE with mod rewrite

   
2:41 pm on Nov 16, 2010 (gmt 0)

5+ Year Member



Anyone now if mod_rewrite engine includes an underscore with \w, like Perl, some engines don't as I understand it? I know rewrite supports the char class alnum.

\w = [a-zA-Z0-9_]
[:alnum:] = [a-zA-Z0-9]

RewriteCond %{QUERY_STRING} f=(\w+)
OR
RewriteCond %{QUERY_STRING} f=([[:alnum:]_])

I'll have time to set up a test HTTP Server later but not today, so I can't test myself. Apologizes! I hate asking questions I can get the answer to myself but I need to know today.

Cheers.
4:07 pm on Nov 16, 2010 (gmt 0)

10+ Year Member



Apache supports PCRE, however it doesn't (appear to) know about things like [:alnum:] used. I was able to use \w and \d, for example.

[httpd.apache.org...]

Tom
10:55 pm on Nov 17, 2010 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



When in doubt, use the old-style POSIX expressions for best results (and portability). Use of the [NC] flag on the RewriteCond or RewriteRule (as applicable) can make this slightly less painful, so as to avoid having to specify both upper- and lower-case ranges.


Jim