最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

permalinks - Changing pemalink structure to %post_id%%postname%

programmeradmin1浏览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?

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?

Share Improve this question asked Nov 7, 2018 at 11:15 bikegremlinbikegremlin 18610 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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/2018/11/04/hello-world/ from my browser:

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/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/postID (with or without trailing slash) and the browser goes to example/postID/ (with a trailing slash) directly, showing the contents of example/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/6768/permalink-change/

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/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.

发布评论

评论列表(0)

  1. 暂无评论