Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove query strings from 301 redirect

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

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  

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 

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.

Really appreciate any help.

like image 338
Ash Avatar asked May 22 '12 18:05

Ash


1 Answers

two options:

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

or:

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)

like image 94
kaptinkaos Avatar answered Oct 05 '22 20:10

kaptinkaos