I need to know if it is possible, having a regular expression, used in a mod_rewrite, to match a non-predictable number of times a certain sequence and access the matches using a backreference to each of them.
An example avails more than many words:
sequence to match:
0102030405....
(sequence length= n*2, where n could be a number greater or equal to 1)
regular expression:
([0-9][0-9]+)
I would need to be able to get each of the n matches in the sequence, in order to use them in a mod_rewrite rule, that would give the following translations:
/01.html => /01/index.html
/0102.html => /01/02/index.html
/010203.html => /01/02/03/index.html
/01020304.html => /01/02/03/04/index.html
...
Would that be possible to get this?
You can use these 2 rules for that:
RewriteRule ^(.+?/)?([0-9]{2})\.html$ /$1$2/index.html [L]
RewriteRule ^(.+?/)?([0-9]{2})([0-9]+.+?\.html)$ /$1$2/$3 [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.