How to Redirect huge numbers of URLs to another URLs?

I am going to move from Blogger to WordPress and I also don’t want to set earlier Blogger Permalink structure in WordPress.
Now I want to know if there is any way to redirect URLs as mentioned below.

Current (In Blogger):

http://www.example.com/2017/10/seba-online-form-fill-up-2018.html

After (In WordPress):

http://www.example.com/seba-online-form-fill-up-2018.html

That means I want to remove my Blogger’s year & month from URL from numbers of indexed URL and redirect them to WordPress generated new URLs.

2 Answers
2

If /seba-online-form-fill-up-2018.html is an actual WordPress URL then this is relatively trivial to do in .htaccess. For example, the following one-liner using mod_rewrite could be used. This should be placed before the existing WordPress directives in .htaccess:

RewriteRule ^\d{4}/\d{1,2}/(.+\.html)$ /$1 [R=302,L]

This redirects a URL of the form /NNNN/NN/<anything>.html to /<anything>.html. Where N is a digit 0-9 and the month (NN) can be either 1 or 2 digits. If your Blogger URLs always have a 2 digit month, then change \d{1,2} to \d\d.

The $1 in the substitution is a backreference to the captured group in the RewriteRule pattern. ie. (.+\.html).

Note that this is a 302 (temporary) redirect. You should change this to 301 (permanent) only when you have confirmed this is working OK. (301s are cached hard by the browser so can make testing problematic.)

Leave a Comment