httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Valentin Guggiana <>
Subject Re: [users@httpd] Stripping trailing numbers with mod_rewrite
Date Thu, 26 Aug 2004 12:33:27 GMT
Robert Andersson wrote:
> Valentin Guggiana wrote:
>>I want to rewrite my URLs depending on username without
>>trailing numbers, e.g. with REMOTE_USER = user12345 :
>>/doc/logo.gif  -->  /doc/user/logo.gif
> This may work:
>     RewriteCond %{REQUEST_URI} ^/doc/(.*)
>     RewriteCond %{LA-U:REMOTE_USER} ^(.+?)\d*$
>     RewriteRule ^/doc/(.*) /doc/%1/$1 [NS]
> Here you capture the username without trailing numbers in the condition, and
> then use it in the rule.
> If the username cannot have numbers in them, except the trailing ones (like
> 1337user12345), you should change the second condition's pattern to
> "^([^\d]+)". Do use this pattern if you can.
> If you have problems with the above, please explain the exact rules for how
> a valid username can be constructed.

That's exactly what I want! I'm new (started yesterday) in using mod_rewrite
and regular expressions. I missed back-references to RewriteCond and \d
for matching number.

Thanks for your help,

Valentin Guggiana

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message