Custom URL Rewrite
-
Hi,
I’m using
add_rewrite_rule()function to redirect user to a particular URL.Following is the function that I’m using:
function my_custom_rewrite() { add_rewrite_rule( '^my-custom/([^/]*)/?', 'index.php?taxonomy=vehicles&mk=$matches[1]', 'top' ); } add_action( 'init', 'my_custom_rewrite' );With this code, when someone visits http://example.com/my-custom/ford/ it loads the page and content properly.
I tried to modify this function in such a way that user can still access same page using http://example.com/my-custom-ford/
I’ve used following function for that:
function my_custom_rewrite() { add_rewrite_rule( '^my-custom-([^/]*)/?', 'index.php?taxonomy=vehicles&mk=$matches[1]', 'top' ); } add_action( 'init', 'my_custom_rewrite' );Unfortunately, this function returns a 404 error.
Any suggestion or feedback how to achieve http://example.com/my-custom-ford/ working would be great.
TIA
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Custom URL Rewrite’ is closed to new replies.