0

I'm currently using permalink structure: /%year%/%monthnum%/%day%/%postname%/

I want to change that to: /%post_id%/%postname%/

I expect it to be:

  • faster (database is sorted by post_id?)
  • shorter URLs (and clearly visible short verstions, just leaving the %postname%/ out)
  • more SEO friendly - since my content is "evergreen" so publishing date is irrelevant (and written at each post, along with last update date) - so this would give shorter URLs, with no downsides compared to using year/month/day structure.

THE QUESTION: Does WordPress handle all the 301 redirects automatically? I can fix internal links to the new structure (though I'd expect that to be automatic as well), but worry about outsite links, pointing to my posts/articles.

If not, what's the best way to implement this change? Any links or full answers here are welcome.

I have about 120+ posts already, will this change affect the speed since it's not been done from the start?

2 Answers 2

1

I think I got it. Made a test site. With permalink structure:

year/moth/day/postname.

Published a post. Then changed permalinks to postID/post-name. Tested with looking at network stats from the browser. Here's what I got, a 301 redirect, after trying example.com/2018/11/04/hello-world/ from my browser:

what the browser does

I tested another thing. Using different permalink structures, I tried to make two posts with the same post-name (the link part where post-name is). WordPress won't allow it.

My conclusion is that post-name and postID are both unique. This would explain why this auto-301 redirect works, as well as why having a flat directory structure of example.com/post-name isn't so slow performing, as it was before WordPress 3.3. (I think) version.

Another interesting thing is that, using permalink structure of postID/post-name, I can enter in a browser: example.com/postID (with or without trailing slash) and the browser goes to example.com/postID/ (with a trailing slash) directly, showing the contents of example.com/postID/post-name.

So this seems to be nicely sorted out, no need to worry about manually setting 301 redirects, either with .htaccess entries (my planned change would have required manual redirect for each post), since I'm adding a unique ID in the link structure). No need for plugins as well.

What needs to be done is change all the internal links - WordPress doesn't automatically change them. It does 301 redirects, but the old links remain. That's a bother.

Full article explaining the problem, how I tested, and some speed test results: https://io.bikegremlin.com/6768/permalink-change/

0

Sorry nope, WP can't handle all the 301 redirects automatically. You have to do rewrite rules, or use rewrite plugin (like "redirection", or others) to manage that manually.

if you like use .htacces file, you can add :

# BEGIN 301 Redirects
Redirect 301 /2018/11/07/my-post/ http://www.mydomaine.com/postid/my-post/
# END 301 Redirects

To go fast, you can do a DB request to print this list of rules. Just copy/past on .htaccess after.

3
  • Since post id is unique, there's no way to do this quickly, but making manual redirects for each post if I understand correctly? Does a long list of redirect rules slow the server down? Does WordPress "fix" the internal links autmoatically at least? Commented Nov 7, 2018 at 13:37
  • Just tried with a sample website. Switching permalink structure from year/month/day/postname to post_id/postname, from WordPress Permalinks menu. Without any .htaccess changes or redirect plugins. It seems to redirect!?! Automatically. I try old URLs of a few test posts and they are redirected using the new permaling structure!? Not sure where it's implemented - the redirects - database, or somewhere else, will look into it. Commented Nov 7, 2018 at 16:11
  • Apparently, WordPress makes 302 redirects, according to this: moz.com/blog/… Commented Nov 7, 2018 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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