admin管理员组文章数量:1023764
We have recently done a massive migration from a custom CMS to Wordpress CMS however want to figure out the right way to do 301 redirects from a situation where their previous URLs did not have any sort of date in the permalink but new one does
Old permalink: /category/subcategory/1234/slug (1234 = post id)
New permalink: /category/subcategory/YYYY/MM/DD/slug
What is the best way to do 301 for over 60k articles that follow this structure?
We have recently done a massive migration from a custom CMS to Wordpress CMS however want to figure out the right way to do 301 redirects from a situation where their previous URLs did not have any sort of date in the permalink but new one does
Old permalink: /category/subcategory/1234/slug (1234 = post id)
New permalink: /category/subcategory/YYYY/MM/DD/slug
What is the best way to do 301 for over 60k articles that follow this structure?
Share Improve this question asked Jan 18, 2019 at 14:42 HossjHossj 1214 bronze badges1 Answer
Reset to default 0Generally, you can use .htaccess (a file located at the root of the folder you are serving) and a regular expression to do the redirect. I used Yoast to generate mine:
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(?!page/)(.+)$ https://example/$4
In the regular expression above I match anything at the beginning then I match / followed by 4 digits (a year) followed by / followed by 2 digits (a month) followed by / followed by 2 digits (a day) followed by the page slug. $4 points to the 4th variable in (...). See here for explanations.
In your example, though, you need to retrieve the date information given the post identifier. In this case, you may find it easier to use a Wordpress plugin that will handle the redirection for you. This one (top result in Google) should do the trick.
PS: SEO best practices recommend moving away from date-based URLs. I am in the process of doing just that on my own sites. What's your reasoning for going the other way?
We have recently done a massive migration from a custom CMS to Wordpress CMS however want to figure out the right way to do 301 redirects from a situation where their previous URLs did not have any sort of date in the permalink but new one does
Old permalink: /category/subcategory/1234/slug (1234 = post id)
New permalink: /category/subcategory/YYYY/MM/DD/slug
What is the best way to do 301 for over 60k articles that follow this structure?
We have recently done a massive migration from a custom CMS to Wordpress CMS however want to figure out the right way to do 301 redirects from a situation where their previous URLs did not have any sort of date in the permalink but new one does
Old permalink: /category/subcategory/1234/slug (1234 = post id)
New permalink: /category/subcategory/YYYY/MM/DD/slug
What is the best way to do 301 for over 60k articles that follow this structure?
Share Improve this question asked Jan 18, 2019 at 14:42 HossjHossj 1214 bronze badges1 Answer
Reset to default 0Generally, you can use .htaccess (a file located at the root of the folder you are serving) and a regular expression to do the redirect. I used Yoast to generate mine:
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(?!page/)(.+)$ https://example/$4
In the regular expression above I match anything at the beginning then I match / followed by 4 digits (a year) followed by / followed by 2 digits (a month) followed by / followed by 2 digits (a day) followed by the page slug. $4 points to the 4th variable in (...). See here for explanations.
In your example, though, you need to retrieve the date information given the post identifier. In this case, you may find it easier to use a Wordpress plugin that will handle the redirection for you. This one (top result in Google) should do the trick.
PS: SEO best practices recommend moving away from date-based URLs. I am in the process of doing just that on my own sites. What's your reasoning for going the other way?
本文标签: permalinksHow to 301 redirect from one url to another properly
版权声明:本文标题:permalinks - How to 301 redirect from one url to another properly 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745514725a2153986.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论