httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Andersson" <rob...@profundis.nu>
Subject Re: [users@httpd] Stripping trailing numbers with mod_rewrite
Date Thu, 26 Aug 2004 12:04:41 GMT
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.

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message