[英]Rewrite custom url Wordpress
I've this url in Wordpress: 我在Wordpress中有这个网址:
http://mywebsite.com/examples/detail/?id=6341
I want to change this like that: 我想改变这样:
http://mywebsite.com/examples/detail/id/6341
So I wrote this into functions.php
所以我把它写进了
functions.php
function custom_rewrite_basic() {
add_rewrite_rule('^examples/detail/?id=([0-9]+)/?', 'index.php?id=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic');
But it does not work. 但它不起作用。
Try to update RegEx to catch what you want to see in URL and redirect accordingly: 尝试更新RegEx以捕获您希望在URL中看到的内容并相应地重定向:
function custom_rewrite_basic() {
add_rewrite_rule('^examples/detail/id/([0-9]+)/?', 'index.php?id=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.