2

http://www.domain.com/old-name-here?manufacturer=445应显示为:

http://www.domain.com/new-name-here/brand-name

如果我输入以下 htaccess 代码:

重定向 301 /old-name-here?manufacturer=445 /new-name-here/brand-name-here

它确实通过 301 正确重定向,但它将查询字符串保留在末尾,并且仅重定向第一个文件夹...

4

1 回答 1

0

Redirect指令不能匹配 QUERY_STRING。你应该使用mod_rewrite规则。

您可以在DOCUMENT_ROOT/.htaccess文件中使用此规则:

重写引擎开启

RewriteCond %{QUERY_STRING} (^|&)manufacturer=45(&|$) [NC]
RewriteRule ^old-name-here/?$ /new-name-here/brand-name-here? [NC,L,R=301]

?最后将从目标 URI 中删除任何现有的查询字符串。

于 2013-11-12T20:33:31.207 回答