Using latest versions of WordPress & Woocommerce.
If I have 2 pages of products in my shop & I click PAGE 1 in my pagination links, I get a 301 redirect that goes to /shop.
For SEO purposes I’d like to disable the 301 redirect & keep the link as it is in the pagination links i.e /shop/page/1
This seems to be the default behaviour in Woocommerce & it’s not something my Shopkeeper theme is doing.
3
Answers
Had the same issue with a site I’m building. Although you’re asking to keep /shop/page/1/ (with no 301) it is actually better to simply have /shop/ as your page one. Otherwise you have two identical pages serving up the same content which Google is not fond of.
The approach I took was to change the output of the pagination to NOT include /page/1/ in the link. This then removes the 301 as the link is correct to start with. To do this I used the filter
paginate_links
.Hope this helps.
You can use the following regex to match only page 1. The answer by SaRiD will also match pages 10 – 19, 100+ etc as they all start with 1.
The answer by SaRiD will match all page numbers starting with a 1.
The answer by Christopher Geary uses preg_replace, which is unnecessary and should be avoided if possible.
If you don’t need fancy replacing rules (like regular expressions), you should use this function instead of preg_replace().
The following solution works with str_replace and only! if the trailing slash in WordPress permalinks is not disabled and there is no further path part /page/1/ in permalinks.
Thanks to SaRiD and Christopher Geary for your previous answers.