开发者

Help me write a Regex RewriteRule for htaccess

I need help writing a simpl开发者_如何学Ce regex for RewriteRule for mod_rewrite in htaccess. So, here is what I am trying to accomplish:

books/2010-the-world-by-hopkins-139_PPS-1234567

should go to

index.php?pagename=mypage&PPS=1234567&description=2010-the-world-by-hopkins-139

So, in pseducode, the regex has to split the part after books by _ and I should get it into two parts:

  1. PPS (it is always a numeric with 1+ variable number of digits). This is the part after _PPS-
  2. Description (it is always a string). This is the part containing ANYTHING before the _.

I guess the RewriteRule will be something like:

RewriteRule books/(.*)_(.*) index.php?pagename=mypage&PPS=$2&description=$1

But I need correct regex. Plese help.


something like: but flip the $1 and $2 ;)

^books/(.*)_PPS-([0-9]{1,})$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜