I have a page named "city":
http://localhost/wordpress/city/
It gets details from MySQL by URL id like:
http://localhost/wordpress/city/?id=paris
I want to change it like:
http://localhost/wordpress/city/paris
The real link of the city page in WordPress is:
http://localhost/wordpress/index.php?p=5
I try add_rewrite_rule
, but it doesn't work:
add_action( 'init', 'add_mypage_rule' );
function add_mypage_rule() {
add_rewrite_tag("%id%", '(\d+)');
add_rewrite_rule('^city/([^/]*)/?','index.php?p=5&id=$matches[1]','top');
}
What add RewriteRule
should I use for .htaccess
?