This question already has answers here: Changing pemalink structure to /%post_id%/%postname%/ (2 answers) Closed 6 years ago.admin管理员组文章数量:1130349
Interesting thing I tried on a test site: I switched permalink structure from date/postname to postID/postname. From WordPress Permalinks panel - no plugins, no .htaccess entries, nothing, just switched permalink structure. Then tried old post links, using the date/postname link. They were automatically redirected to the new address (postID/postname). I see no changes to .htaccess (made by WordPress).
Any idea how WordPress implements this? Does it affect performance?
This question already has answers here: Changing pemalink structure to /%post_id%/%postname%/ (2 answers) Closed 6 years ago.Interesting thing I tried on a test site: I switched permalink structure from date/postname to postID/postname. From WordPress Permalinks panel - no plugins, no .htaccess entries, nothing, just switched permalink structure. Then tried old post links, using the date/postname link. They were automatically redirected to the new address (postID/postname). I see no changes to .htaccess (made by WordPress).
Any idea how WordPress implements this? Does it affect performance?
Share Improve this question asked Nov 7, 2018 at 16:21 bikegremlinbikegremlin 18610 bronze badges 5 |1 Answer
Reset to default 1I 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.
EDIT: after a month on a live site, wrote in detail about results, how the redirect is made, how I tested: WordPress permalink change
This question already has answers here: Changing pemalink structure to /%post_id%/%postname%/ (2 answers) Closed 6 years ago.Interesting thing I tried on a test site: I switched permalink structure from date/postname to postID/postname. From WordPress Permalinks panel - no plugins, no .htaccess entries, nothing, just switched permalink structure. Then tried old post links, using the date/postname link. They were automatically redirected to the new address (postID/postname). I see no changes to .htaccess (made by WordPress).
Any idea how WordPress implements this? Does it affect performance?
This question already has answers here: Changing pemalink structure to /%post_id%/%postname%/ (2 answers) Closed 6 years ago.Interesting thing I tried on a test site: I switched permalink structure from date/postname to postID/postname. From WordPress Permalinks panel - no plugins, no .htaccess entries, nothing, just switched permalink structure. Then tried old post links, using the date/postname link. They were automatically redirected to the new address (postID/postname). I see no changes to .htaccess (made by WordPress).
Any idea how WordPress implements this? Does it affect performance?
Share Improve this question asked Nov 7, 2018 at 16:21 bikegremlinbikegremlin 18610 bronze badges 5- Are you sure you don't have a SEO plugin that automatically created the redirect? – kero Commented Nov 7, 2018 at 16:29
-
1
The function that does this is
redirect_guess_404_permalink, you can look in the source code and see what it does. – Milo Commented Nov 7, 2018 at 16:50 - No plugins for SEO, it was tested on a test site - so few posts and pages, for testing and that's it. – bikegremlin Commented Nov 7, 2018 at 16:54
- Apparently, WordPress makes 302 redirects, according to this: moz/blog/… – bikegremlin Commented Nov 7, 2018 at 17:36
- @ReljaNovović that post is almost 6 years old, I don't think WP does any 302 redirects any more. When I test my local install, all I see are 301s. – Milo Commented Nov 8, 2018 at 3:52
1 Answer
Reset to default 1I 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.
EDIT: after a month on a live site, wrote in detail about results, how the redirect is made, how I tested: WordPress permalink change
本文标签: Permalink change redirects by WordPress
版权声明:本文标题:Permalink change redirects by WordPress 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749121276a2319049.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


redirect_guess_404_permalink, you can look in the source code and see what it does. – Milo Commented Nov 7, 2018 at 16:50