从301重定向删除查询字符串 [英] Remove query strings from 301 redirect

查看:212
本文介绍了从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)

这篇关于从301重定向删除查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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