How to use .htaccess to ignore/remove /page/X/ from url?

How can I use .htaccess to strip/ignore /page/X/ where X is the page number, from my urls, ONLY if it’s right after the domain.com, like domain.com/page/29/ ?

Scraper sites are linking to my site with pagination on posts for some reason, causing Google to crawl those links. Unfortunately my site is not showing a 404, but instead showing a page, and the canonical url is including /page/29/ for example. It’s not good. Hurting my rankings.

Read More

How would this be done in htaccess, so that pagination after anything else like a /page-name/ would still work?

Related posts

Leave a Reply

1 comment

  1. You can try the following rule if you want to rewrite /page/X/ to /page/ exactly. (where X is any number)

    RewriteRule ^page/([0-9]+)/$ http://domain.com/page/ [R=302,L]
    

    If you want to rewrite /[anystring]/X/ to /[anystring]/ you can try

    RewriteRule ^(.*)/([0-9]+)/$ http://domain.com/$1/ [R=302,L]