1

我想重定向以下两个链接:

/catalog/yogicchai/rooibos-masala-chai-naturally-caffeine-c-84.html?infoBox=5 (category link)


/catalog/yogicchai/rooibos-masala-chai-naturally-decaffeinated-p-291.html (product link)

至:

yogicchaiDOTcom/rooibos-masala-chai-naturally-decaffeinated.html

我认为这是解决方案:

RedirectMatch 301 /catalog/yogicchai/rooibos-masala-chai(.*)\.html 
yogicchaiDOTcom/rooibos-masala-chai-naturally-decaffeinated.html

但最终结果是:

yogicchaiDOTcom/rooibos-masala-chai-naturally-decaffeinated.html?infoBox=5

我不想"?infoBox=5"打印在上面 URL 的末尾

我怎样才能防止这种情况发生?

4

2 回答 2

2

只需将问号添加到目标 URL,如下所示:

RedirectMatch 301 /catalog/yogicchai/rooibos-masala-chai(.*)\.html 
yogicchaiDOTcom/rooibos-masala-chai-naturally-decaffeinated.html?

一个url中不能有两个问号,所以apache不会添加上一页的参数,因为new里面已经有一个了。

于 2014-10-13T13:02:56.277 回答
0

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^catalog/yogicchai/rooibos-masala-chai.*?\.html$ /rooibos-masala-chai-naturally-decaffeinated.html? [L,R=301,NC]
于 2013-04-03T21:35:13.423 回答