我重新设计了这个网站,并试图创建一个301重定向将旧链接重定向到新的链接,以保存现有的谷歌pagerank。我正在使用joomla为我的网站。
链接的例子:
- 旧链接:
frutaplantaonline.nl/cgi-bin/index.pl?n=823&txt=privacy_policy
- 新增链接:
frutaplantaonline.nl/privacy-policy
我试着:
Redirect 301 /cgi-bin/index.pl?n=823&txt=privacy_policy http://frutaplantaonline.nl/privacy-policy
RewriteRule ^/?cgi-bin/index.pl?n=823&txt=privacy_policy/?$ http://frutaplantaonline.nl/privacy-policy [L,R=301]
所有的链接都有cgi-bin/index.pl
,如果我删除index.pl
中的点,我可以重定向网站。
已经搜索了几个小时,但没有找到解决方案,如果有人能帮助我,我会很感激!
Redirect
指令在你的情况下是无用的,因为它只适用于路径(即/cgi-bin/index.pl
)。
您需要使用RewriteRule
指令并伴随RewriteCond
来匹配查询字符串。来自官方文档:
如果希望匹配主机名、端口或查询字符串,请分别使用带有%{HTTP_HOST}、%{SERVER_PORT}或%{QUERY_STRING}变量的RewriteCond。
在你的例子中,像这样可以:
RewriteCond %{QUERY_STRING} n=823&txt=privacy_policy
RewriteRule ^/cgi-bin/index.pl$ http://frutaplantaonline.nl/privacy-policy [R=301,L]