我很难通过 301 重定向在 htaccess 中捕获组。
我的规则是RedirectMatch 301 ^/viewitems/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+) http://example.com/catalogsearch/result/?q=$2&dir=desc&order=relevance
但有一个测试网址
http://example.com/viewitems/underground-hardwar/manhole-cable-hooks
它构建了一个如下所示的 url:
http://example.com/catalogsearch/result/?q=manhole-cable-hooks/viewitems/underground-hardwar/manhole-cable-hooksdir=desc/viewitems/underground-hardwar/manhole-cable-hooksorder=relevance
显然,用&
每个捕获组替换每个。发生了什么事,我做错了什么?