I have a blog news from 1 year with around 1500 articles indexed on Google with this permalink structure (I know it is bad...):

/%category%/%postname% (without slash!)

Now I would like to change permalink structure without loosing SEO to:

/%post_id%_%postname%/ (or maybe is better this one -> /%postname%/%post_id%/)

I wrote this rule for the .htaccess but I am not sure it work well:

RewriteRule ^/([^/]+)/([^/]+)$ ^/(\d+)_([^/]+)/$ [R=301,L]

Thanks for your help!

  • Or maybe i have to use it?...: RedirectMatch 301 ^/([^/]+)/([^/]+)$ URL/(\d+)_$2/ I am not sure if it is works well. Nov 6 '18 at 20:57

postID/postname should work faster.

Had a similar dilema and it turned out WordPress did all the 301 redirects automatically:

Changing pemalink structure to /%post_id%/%postname%/

Didn't measure any rating or traffic drop. However, in the first week, page load time did increase because of most visits being redirected. After that, all fine.

Make sure to change all the internal links, so they point to the new address, otherwise, users clicking on them will be redirected. Not very bad, but not perfect either.

  • Thank you... I will try it and I will let you know. (Honestly I am a bit worried!...) Mar 2 '19 at 4:13
  • Is this versione the same? /%post_id%_%postname%/ ? Or.... it works only /%post_id%/%postname%/ ?? Mar 2 '19 at 5:05
  • Semantically they are the same. Technically, they differ. WordPress permalink custom line should say: htt-stuff://YOUR-DOMAIN/%post_id%/%postname%/ Mar 3 '19 at 7:26
  • Note: I put it all (for future reference/reminder) here: bike.bikegremlin.com/6768/permalink-change All explained, plus a list of links I had found useful. Mar 3 '19 at 8:19
  • I read the article but I have a doubt. You wrote "This allows for the fastest possible database search (and website performance) and I can easily create short links, like for this post: “bike.bikegremlin.com/6768/”. Very convenient for posting links on Twitter, or Instagram, for example.". Could it generate double content on google? If I check "bike.bikegremlin.com/6768/" and "bike.bikegremlin.com/6768/permalink-change" I receive a 200 status code for both. Mar 4 '19 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.