Rewrite rule ignore what’s in front

I would like to rewrite

http://www.example.com/a/b/c/d/S123

Read More

with endless virtual subdirectories (keywords) to

http://www.example.com/?id=123

But it seems my rule is only working for

http://www.example.com/S123 (without “subdirectories”).

What is wrong on this rule?

^S(?:.+/)?(d+)/?$

Related posts

Leave a Reply

1 comment

  1. ^S… means that your url segment STARTS with S which is true for /S123 and not for a/b/a/S123.

    use this regex instead :

    ^.*S(?:.+/)?(d+)/?$