0

我无法从重定向 htaccess 中删除查询字符串。我为此尝试了很多并在谷歌上搜索了 als ..但似乎没有任何效果

这是我的代码:

首先我尝试了这个但没有奏效:

Redirect 301  /my_page.aspx?ps=22.5000&pe=44.9900 http://www.mysite.com/35-new-items

然后我尝试了:

 RewriteCond %{QUERY_STRING} (^|&)ps=
 RewriteCond %{QUERY)STRING{ (^|&)pe=4
 RewriteRule ^/?my_page\.aspx$ /35-new-items? [L,R=301]

但这同样对我不起作用。

然后我尝试了这个,像往常一样这似乎也不起作用:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(?:my_page\.aspx)?\?p=1 [NC]
RewriteRule ^ /35-new-items? [R=301,L]

请帮我 !

我必须将具有不同查询字符串值的旧页面重定向到新页面。旧页面在 ASPX 中,新页面在 PrestaShop 中。

所以它重定向为http://www.mysite.com/35-new-items?ps=22.5000&pe=44.9900

如何删除这部分:

 ?ps=22.5000&pe=44.9900

从目标网址?

4

2 回答 2

0

我的要求是谷歌 SEO,所以我所做的是因为我的页面正在重定向,所以我使用这个 smarty 代码从当前 url 中删除了我的查询字符串值

{$res=$smarty.server.REQUEST_URI|regex_replace:"~\?[^/]++~":" "} 

并使用

<link rel="canonical" href="{Tools::getCurrentUrlProtocolPrefix()}{$smarty.server.HTTP_HOST}{$res}" />

以便可以应用规范化以避免重复的页面内容

于 2013-11-18T14:34:57.030 回答
0

这会更好(在 Debian/Apache2 上测试):

RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)(ps|pe)= [NC]
RewriteRule ^/?my_page\.aspx$ /35-new-items? [L,R=301]
于 2013-11-18T11:59:03.107 回答