0

I would like to remove certain URL parameters from my site, so Googlebot doesn't get confused & thinks it's duplicate content.

The parameters are:

  • ?sort=
  • ?limit=
  • ?order=

Based on some examples I've come across, here's what I'm currently using in .htaccess:

RewriteCond %{QUERY_STRING} "sort=" [NC]
RewriteRule (.*) /$1? [R=301,L]

RewriteCond %{QUERY_STRING} "limit=" [NC]
RewriteRule (.*) /$1? [R=301,L]

RewriteCond %{QUERY_STRING} "order=" [NC]
RewriteRule (.*) /$1? [R=301,L]

What is the proper syntax to combine these parameters into one rule?

2 Answers 2

1

It is not a good solution to remove the parameters if you need them.

The best way to avoid problems related to duplicate content, is to add in the html <head>:

<link rel="canonical" href="http://www.domain.com/url-file.php?param=xxx">

By indicating the complete url of the page, with the only parameters you want to index by Google.

Sign up to request clarification or add additional context in comments.

1 Comment

0

You can use alternation in regex:

RewriteCond %{QUERY_STRING} ^(limit|sort|order)= [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L,NE]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.