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/
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/
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:
/page/(\d*)/
/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.
.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