从301重定向删除查询字符串

问题描述:

我奋力创​​造适当的301重定向使用的查询字符串最初建一个网站。旧的URL结构是这样的:

I am struggling to create appropriate 301 redirects for a site that was originally built using query strings. The old URL structure looks like this:

http://www.oldsite.com/about/index.cfm?fuseaction=cor_av&artID=5049

我想整个的子文件夹(名为关于),以一个新的页面重定向的新域。新域名的URL看起来是这样的:

I want to redirect the entire subfolder (named 'about') to a new page on the new domain. The new domain's URL looks like this:

http://www.newsite.com/info

因此​​,我成立了一个重定向,看起来像这样:

So, I set up a redirect that looks like this:

redirectMatch 301 ^/about/ http://www.newsite.com/info  

据重定向就好了,但它保持了原有的URL字符串连接,使新的URL结束了在浏览器看起来像这样:

It is redirecting just fine, but it's keeping the original URL string attached, so the new URL ends up looking like this in a browser:

http://www.newsite.com/info/?fuseaction=cor_av&artID=5049 

我肯定是不够的一个Apache / 301专家OT知道如何解决这个问题。我只是想去掉一切从?上。

I'm definitely not enough of an Apache/301 expert ot know how to fix this. I just want to strip off everything from the ? on.

真的AP preciate任何帮助。

Really appreciate any help.

两个选项:

redirectMatch 301 ^/about/ http://www.newsite.com/info? 

RewriteEngine on
RewriteRule ^about/(.*) http://www.newsite.com/info? [L,R=301]

在端问号似乎是关键位。第二个看起来有点清洁(第留下问号在您的网址的结尾)

question mark at the end seems to be the critical bit. Second one looks a little cleaner (first leaves a question mark at the end of your URL)