I have a problem. I want to move my blog posts into a /blog/ directory and redirect all current post URLs to their respective new URLs to avoid 404 errors.
With 100+ blog posts, I’d rather redirect the URLs en masse, but here’s the catch: only the blog should be redirected. Pages should remain at their current URLs. So the question becomes: how do I 301 redirect all URLs except pages?
I’ve done my share of googling on this. I’ve found a few helpful posts, but nothing has worked for me yet. Here are a few snippets I’ve tried in my .htaccess so far.
I’m using a plugin called Redirection. It’s been helpful so far, but it doesn’t help me here. I need to come up with the regex formula on my own to target posts. I posted in Redirection plugin support forum asking that community for help.
Redirection does allow me to import redirects in bulk using htaccess, CSV, or XML. But, again, that assumes I either write them all out individually or figure out on my own how to regex them. That’s the part I need help with.
I don’t know enough about Apache/mod_rewrite/htaccess/regex to know what each line of my htaccess file does. The above lines are easy enough to understand. But there’s a bunch of other stuff in that file that I don’t quite get, most of it inserted by WordPress or other plugins.
Any help on how to 301 redirect all URLs except pages would be greatly appreciated!