[英]How can I catch an id in static urls and redirect it to new urls in wordpress [301]
I need to redirect old urls structure to new one in wordpress with 301, here is one of my old urls 我需要将301中的旧网址结构重定向到新的WordPress中,这是我的旧网址之一
example.com/en/news/1/13005/post_title
I want to catch 13005
which is the post id and redirect url to new structured parameter base wordpress url : 我想捕获
13005
,这是发布ID,并将url重定向到新的结构化参数库wordpress url:
example.com/?p=13005
For some reasons i might need to add a specific number to all old ids, How can i implement these redirections ? 由于某些原因,我可能需要为所有旧ID添加一个特定的数字,如何实现这些重定向?
You can do this by adding following rules in your .htaccess
file: 您可以通过在
.htaccess
文件中添加以下规则来做到这一点:
RewriteEngine On
RewriteRule ^en/news/([0-9]+)/([0-9]+)/post_title$ http://example.com/?p=$2 [R=301,L]
For dynamic post_title
you can use: 对于动态
post_title
您可以使用:
RewriteRule ^en/news/([0-9]+)/([0-9]+)/(.*)$ http://example.com/?p=$2 [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.