使用 GET 参数时,Apache Redirect 301 失败,例如 ?blah= [英] Apache Redirect 301 fails when using GET parameters, such as ?blah=
问题描述
我为一位客户构建了一个新的 PHP 站点,并希望将排名靠前的 Google 结果从旧站点结构重定向到新站点结构.
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.
我在文档根目录的 .htaccess 文件中放置了几十个重定向 301,虽然有些工作正常,但我遇到了其他一些问题.
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.
推荐答案
虽然 Gumbo 的答案 推理是正确的,我无法让他的 RewriteRule 起作用.
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 Redirect 301 失败,例如 ?blah=的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!