Forum Moderators: phranque
for example how can i grab only the last two directories
1/2/3/4/ are directories and i want to read only 3/4/. So only grab the last 2 directories no matter how many previous directories there are, and rewrite on those two values.
Any help would be appreciated.
[b]/[/b]([^/]+)[b]/[/b]([^/]+)[b]$[/b] or this [b]/[/b]([^/]+)[b]/[/b]([^/]+)[b]/$[/b] would likely be a starting point. It is end-anchored, but not start anchored.
I am guessing it is quite inefficient.
It doesn't work if there are less than three items (because leading / isn't shown to RewriteRule in .htaccess).
You'd need another rule with a start anchor to test for that particular case; like
[b]^[/b]([^/]+)[b]/[/b]([^/]+)[b]$[/b] or this [b]^[/b]([^/]+)[b]/[/b]([^/]+)[b]/$[/b] I suspect that jd probably has a better idea. :-)