httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joshua Slive" <jos...@slive.ca>
Subject Re: [users@httpd] RewriteRule advice
Date Mon, 06 Aug 2007 16:11:05 GMT
On 8/6/07, wi <icebattle@gmail.com> 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.

Joshua.

---------------------------------------------------------------------
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