3

I'm trying to set 301 redirects on pages that have 'page=1' in the URL to stop duplicate content issues.

e.g.

http://www.domain.com/reviews/?page=1 to http://www.domain.com/reviews/

I've tried all of the variations I can find and can't seem to get anything to work.

RewriteRule ^reviews(/)?page=1$ http://www.domain.com/reviews/ [L,R=301]

RewriteRule ^(.*)/?page=1 http://www.domain.com/reviews/ [R=301,L]

RewriteCond %{QUERY_STRING} page=1
RewriteRule ^reviews$ http://www.domain.com/reviews/ [R=301,L,NE]

None of these have worked. I'm not really sure what else to try.

There are multiple different sections of the site that I need to do this for:

reviews
news
videos
accessories
hardware

An overall solution to redirect all ?page=1 URLs to their relevant section would be best.

James
  • 739
  • 7
  • 13

2 Answers2

2

Use this code to redirect every URI with ?page=1 to one without the query parameter:

RewriteCond %{QUERY_STRING} ^page=1(&|$) [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L]

Or else if you want to redirect ONLY /reviews URI then

RewriteCond %{QUERY_STRING} ^page=1(&|$) [NC]
RewriteRule ^(reviews)/?$ /$1? [R=301,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
1

the question is already answered, i just would like to mention that your rules are not working because you didn't append a trailing ? to the new url in the rewrite rule

Amine Hajyoussef
  • 4,381
  • 3
  • 22
  • 26