Regex 使用htaccess转换带有连字符的尾部斜杠

Regex 使用htaccess转换带有连字符的尾部斜杠,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,我是一个非常初学者。ht访问。。。但我想知道如何将后面的斜杠改为连字符,并将.html放在末尾 我的.htaccess RewriteRule ^/?product/([a-z0-9\-]+)\/?([0-9]+)$ index.php?menu=product&perma=$1&lang=en&year=$2 [L] 它给了我localhost/product/name/year 但我需要的结果是 localhost/something-product-name-so

我是一个非常初学者。ht访问。。。但我想知道如何将后面的斜杠改为连字符,并将.html放在末尾

我的.htaccess

RewriteRule ^/?product/([a-z0-9\-]+)\/?([0-9]+)$ index.php?menu=product&perma=$1&lang=en&year=$2 [L]
它给了我
localhost/product/name/year

但我需要的结果是

localhost/something-product-name-something-year.html
试试这个规则:

RewriteRule (?:^|/)product-([a-z0-9-]+)-([0-9]+)/?$ /index.php?menu=product&perma=$1&lang=en&year=$2 [L]

它解决了我的问题结果:localhost/product name year…:)