301重定向呢​​? (问号)不工作在htacces [英] 301 redirect with ? (question mark) not working in htacces

查看:315
本文介绍了301重定向呢​​? (问号)不工作在htacces的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个简单的问题,但我们无法找到为什么301不工作。当我们有一个URL带有问号的301重定向在我们的 .htacces 不工作。例如:

This is probably an easy question, but we can not find why the 301 is not working. When we have a url with a question mark the 301 redirect in our .htacces is not working. For example:

/order/order.html?AddID=1078&Rand=666171759380936096

这样: 重定向301 /order/order.html?AddID=1078&Rand=666171759380936096 http://www.domain.nl

so: Redirect 301 /order/order.html?AddID=1078&Rand=666171759380936096 http://www.domain.nl

在我们的网站管理员工具,我们有8000网址具有相同的结构 /order/order.html?AddID = .... 这说的 404 未找到。我们希望为 301 重定向到了主页,但我们得到了一个 404 找不到网页来代替。当我们使用相同的重定向,只有 /order/order.html ,他将被重定向正确的。

In our webmaster tools we have 8000 url's with the same structure /order/order.html?AddID=.... that say 404 not found. We want to 301 redirect them to the homepage, but we get a 404 not found page instead. when we use the same redirect with only /order/order.html he is redirected correct.

推荐答案

您不能针对一个重定向语句的查询字符串匹配,使用mod_rewrite和比赛反对%{QUERY_STRING} VAR:

You can't match against the query string in a Redirect statement, use mod_rewrite and match against the %{QUERY_STRING} var:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^AddID=1078&Rand=666171759380936096$
RewriteRule ^order/order.html$ http://www.domain.nl/? [L,R=301]

不过既然你有这样的开始与查询字符串 ADDID = ,那么你可以只匹配了8000网址:

But since you have like 8000 URLs that start with the query string ?AddID=, then you can just match against that:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^AddID=[0-9]
RewriteRule ^order/order.html$ http://www.domain.nl/? [L,R=301]

这篇关于301重定向呢​​? (问号)不工作在htacces的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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