在网址/ us-en /中检测到其他内容的特定模式

时间:2018-11-27 10:12:04

标签: regex .htaccess directive

我正在寻找一种用另一部分替换网址中的部分的方法。

以下是网址:

http://localhost:8888/sa-ar/product-list.html?category=154

我想用/ web /

代替/ sa-ar /

知道/ sa-ar /可能会动态更改为其他任何国家和语言,例如/ us-en /等。

什么是能够检测到/ sa-ar /

模式的正确正则表达式

到目前为止,这是我已经完成的工作\/(\S{2}-\S{2})\/,除了将其应用于.htaccess之外,其他方法均无效

1 个答案:

答案 0 :(得分:1)

RewriteRule ^[a-z]{2}-[a-z]{2}/(.+) /web/$1 [R=301,L]