[Gllug] Regular expressions and mod_rewrite

Bruce Richardson itsbruce at uklinux.net
Tue Jul 13 14:08:38 UTC 2004


On Tue, Jul 13, 2004 at 02:57:16PM +0100, Simon wrote:
> Hi,
> 
> I'm trying to match the following;
> domain.com/dir/test
> or this
> domain.com/dir/test_underscore
> with...
> Options +FollowSymlinks
> RewriteEngine On
> RewriteBase /
> 
> RewriteRule ^dir/(\w+)$ /re_engine/script.php?var1=$1
> 
> but all I get are 404's
> 
> RewriteRule ^dir/([a-z]+)$ /re_engine/script.php?var1=$1
> matches the top example so mod_rewrite itself is working.
> 
> Anyone see my glaring error?

\w isn't a POSIX regex atom, it's a non-standard extension that
some applications use (mostly ones that use Perl regexes, iirc).
Standard Linux regexes (see "man 7 regex") do support the concept of
word boundaries but don't use \w.  Off hand, I don't know if Apache on
Linux uses the Linux regex library or its own (I'd suspect the latter)
but I'd guess that, in any case, it doesn't support \w.

-- 
Bruce

A problem shared brings the consolation that someone else is now
feeling as miserable as you.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: Digital signature
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20040713/12584709/attachment.pgp>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list