Redirect /blog/yyyy/mm to /blog

Add to htaccess file:
# Q4LAUNCH Added Redirects
RedirectMatch 301 ^/blog/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ https://THE-DOMAIN.com/blog/$3
# END Q4LAUNCH

*Be sure to amend THE-DOMAIN.com
*Be sure to place this ABOVE WP’s default mod_rewrite’s

If you also want to handle/remove extensions
# Q4LAUNCH Added Redirects
#first: remove .html file extension – e.g. https://example.com/file.html will become https://example.com/file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]#then: match, remove and redirect /blog/year/month/
RedirectMatch 301 ^/blog/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ https://whiteoakinn.com/blog/$3
# END Q4LAUNCH

To use the Redirection Plugin instead of accessing the htaaccess file:

  1. Go to Tools > Redirection
  2. Set your source URL to: ^/blog/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$
  3. Set your target URL to: https://THE-DOMAIN.com/blog/$3
  4. Set your group to Modified Posts
  5. Set the URL options /Regex drop-down to “regex”:

  6. Click Add Redirect
  7. Test a few old blog URLs to confirm redirect is working as expected

Leave a Reply