Updating WordPress URL format while preserving SEO with 301 redirects

Hey everyone! I’ve got a WordPress site that’s been using some pretty ugly URLs. They look like this:

mydomain.com/blog/?pid=123456789

I want to switch to something more user-friendly:

mydomain.com/cool-post-title-123456789

The problem is I’ve got tons of content already. I know I need to update the WordPress settings, but I’m stumped on how to redirect the old URLs to the new ones without losing traffic or SEO juice.

Can anyone help me set up the right .htaccess rules? I’m not great with mod_rewrite stuff. How do I make sure visitors and search engines end up at the right place when they use an old link?

Thanks for any advice you can give!

I’ve been through this process a few times and it can be a bit nerve-wracking, but it’s totally doable. Here’s what worked for me: Instead of messing with .htaccess directly, I’d recommend using a plugin like Redirection or Simple 301 Redirects. They’re much more user-friendly and less likely to break your site if you make a mistake. For your specific case, you’ll want to set up a rule that captures the old URL pattern and redirects it to the new one. Something like: From: /blog/?pid=([0-9]+) To: /$post_name-$1, where $post_name is the slug of your post and $1 captures the ID from the old URL. Don’t forget to update your internal links and any hardcoded URLs in your theme or widgets. Also, keep a close eye on your analytics for a few weeks after the switch to catch any issues quickly. Good luck with the update! It’ll be worth it for those cleaner URLs.

Changing URL structures can be tricky, but it’s definitely doable. I’ve gone through this process before, and here’s what worked for me:

First, update your permalink settings in WordPress to the new format you want. Then, use a plugin like Redirection to handle the 301 redirects. It’s much easier than messing with .htaccess directly.

For your specific case, you’ll want to set up a rule that redirects from /?pid=123456789 to /cool-post-title-123456789. The plugin should let you use wildcards to catch all your old URLs.

Don’t forget to update any hardcoded internal links in your content. Also, resubmit your sitemap to Google Search Console after the change.

Monitor your traffic closely for a few weeks to catch any issues. Good luck with the transition!

hey there! i’ve done this before, it’s not as scary as it seems. use a plugin like Redirection, way easier than messing with htaccess. set up a rule to catch old urls and point em to new ones. don’t forget to update internal links and keep an eye on your traffic for a bit after. good luck with the switch, you’ll love those clean urls!