使用GET参数时,如?等等= Apache的重定向301失败 [英] Apache Redirect 301 fails when using GET parameters, such as ?blah=

查看:242
本文介绍了使用GET参数时,如?等等= Apache的重定向301失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个新的PHP网站的客户,并希望从旧网站的结构上的排名谷歌搜索结果重定向到新的一个。

I've built a new PHP site for a customer and want to redirect the top ranking Google results from the old site structure to the new one.

我已经把几十重定向301的在DocumentRoot的一个htaccess的,和我有,而一些做工精细与一群人的问题。

I've put several dozen Redirect 301's in a .htaccess in the documentroot, and while some work fine I'm having issues with a bunch of others.

这工作得很好:

Redirect 301 /nl/flash/banner_new.swf http://www.example.com/actueel/nieuws.html?action=show&f_id=152

这不行! (导致404,因为重定向是简单地跳过):

This doesn't work! (leading to a 404 since the redirect is simply skipped):

Redirect 301 /nl/index.php?mID=24511&subID=0 http://www.example.com/solutions/printsolutions.html
Redirect 301 /nl/index.php?mID=24512&subID=0 http://www.example.com/support/koppeling-met-omgeving.html

在重定向混合在.htaccess文件,只有用GET参数重定向出现故障。

The redirects are mixed in the .htaccess file, and only the redirects with GET parameters appear to fail.

有没有解决办法?忽略重定向失败不是一个选项给客户。感谢您的想法。

Is there a workaround? Ignoring the failing redirects is not an option to the customer. Thanks for your thoughts.

推荐答案

在<一个href="http://stackoverflow.com/questions/1260632/apache-redirect-301-fails-when-using-get-parameters-such-as-blah/1260658#1260658">Gumbo's答案的推理是正确的,我不能让他重写规则的工作。

While Gumbo's answer's reasoning was correct, I could not get his RewriteRule to work.

添加另外的RewriteCond做到了。下面进行了测试,工作正常。

Adding another RewriteCond did it. The following was tested and works fine.

RewriteCond %{REQUEST_URI} /nl/index.php$
RewriteCond %{QUERY_STRING} ^mID=24511&subID=0$
RewriteRule ^.*$ http://www.example.com/solutions/printsolutions.html [L,R=301]

这篇关于使用GET参数时,如?等等= Apache的重定向301失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆