正则表达式在 htaccess 中提取斜杠前的最后一个字符串和整数

regex to extract last string and integer before slash in htaccess

我遇到了以下问题。我想提取由破折号限制的斜线前的最后一个字符串作为变量名,并提取该斜线前的最后一个整数也由破折号限制为该变量的值。

也就是说我要重写这个虚url

http://www.example.com/en/golden-watch-omega-ser-3-712-p/

http://www.example.com/index.php?lang=en&p=712

字符串是动态的,因此可能有 "x" 而不是 "p" 或任何其他字母。

这可能吗?我将不胜感激。

使用以下规则:

RewriteEngine On
RewriteRule ^([a-z]{2})/.*-(\d+)-([a-z])/?$ index.php?lang=&=