1

I've changed the structure from the list of latest posts on the main page to static front page. Latest posts were moved to "blog" page.

I need to redirect (301) old pagination structure from example.com/page/2/ to a new one example.com/blog/page/2/

1 Answer 1

0

1. Plugin: Redirection

This plugin allows you to manage 301 redirections. I played around with the settings and they allows regular expressions which could do the following:

  • http://some.site/page/2/ to http://some.site/blog/page/2/
  • http://some.site/page/3/ to http://some.site/blog/page/3/
  • etc.

They provide documentation on how to set it up which can be found here. This is what I've done when creating the rule, try this:

enter image description here

  • Source URL: /page/(\d*)/
  • Target URL: /blog/page/(\d*)/

I was testing this out on a local copy of WordPress and I don't have anything right now that gives me those URL structures. Let me know if that works for you on your end.

2. Using .htaccess

If you don't want to use a plugin to manage your redirects, add the following to your .htaccess, in between the <IfModule mod_rewrite.c>:

RedirectMatch 301 ^/page/(.+?)(-[0-9]+)?$ /blog/page/$1

This is what your .htaccess should look like if you or a plugin haven't modified it:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Redirect pages to blog
RedirectMatch 301 ^/page/(.+?)(-[0-9]+)?$ /blog/page/$1
</IfModule>

# END WordPress
2
  • I used the second method, simple and convenient. Thank you!
    – user73539
    Commented Aug 28, 2016 at 16:26
  • 1
    Glad to help! Be sure to upvote the answer. Commented Aug 28, 2016 at 16:27

Your Answer

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