I am trying to remove certain url parameters from the urls. Those parameters have no effect on the content being displayed anymore, but google have a bunch of them indexed.
I would like to redirect them to the base url.
Here are the examples.
From www.myexamplesite.com/?start=10
To: www.myexamplesite.com
From www.myexamplesite.com/folder1/?start=10
To: www.myexamplesite.com/folder1
From www.myexamplesite.com/folder2/?start=10
To: www.myexamplesite.com/folder2
Actually I don't need to have any urls with parameters, so I am wondering if there can be a way to catch and redirect all other possible parameters from the urls, and only allow some selected ones that I will specify in htaccess.
Examples:
From www.myexamplesite.com/?param1=10
To: www.myexamplesite.com
From www.myexamplesite.com/?param1=10¶m2=20
To: www.myexamplesite.com
From www.myexamplesite.com/folder1/?param1=10
To: www.myexamplesite.com/folder1
From www.myexamplesite.com/folder1/?param1=10¶m2=20
To: www.myexamplesite.com/folder1
But for param3 which should be my selected one:
From www.myexamplesite.com/folder1/?param3=10
leave untouched: www.myexamplesite.com/folder1/?param3=10
Update
I actually have already implemented a solution, but my main problem is that it always redirect to the home page and not the appropriate REQUEST_URI...
Here is what I have:
RewriteCond %{QUERY_STRING} .
RewriteCond %{QUERY_STRING} !^item=
RewriteCond %{REQUEST_URI} !^/manage
RewriteRule .? http://www.myexamplesite.com%{REQUEST_URI}? [R=301,L]
You can use this rule to strip all query strings except when
param3=
is found in it.