httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joshua Slive" <>
Subject Re: [users@httpd] RewriteRule advice
Date Mon, 06 Aug 2007 16:11:05 GMT
On 8/6/07, wi <> wrote:
> Hi all
> I need to create a rule to map requests such as
> /names/123/data
> to
> /names/1/2/3/data
> I can't control how many digits I need to split up like this, which is where
> my regex skillz are breaking down.

RewriteRule ^/names/([0-9]/)*([0-9])([0-9])(.*) /names/$1$2/$3$4 [N]

Because the N flag is used to make the rule loop, you'll need to be
VERY careful if you have any other RewriteRules, since they'll ALL be
reapplied. If you have other RewriteRules that you don't want to loop,
you could just repeat (copy-past) the above RewriteRule (without the
[N] flag) up to the maximum number of digits you'll need to replace.


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