簡體   English   中英

重寫自定義網址Wordpress

[英]Rewrite custom url Wordpress

我在Wordpress中有這個網址:

http://mywebsite.com/examples/detail/?id=6341

我想改變這樣:

http://mywebsite.com/examples/detail/id/6341

所以我把它寫進了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');

但它不起作用。

嘗試更新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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM