I just need to redirect test.com/buying/properties-for-sale/?property=-north-gorley-11409
to test.com/buying/properties-for-sale/-north-gorley-11409 in wordpress
I have tried the below rewrite but result in 404 page
add_rewrite_rule('/buying/properties-for-sale-salisbury-2/?([^/]*)', 'index.php?pagename=properties-for-sale-salisbury-2&property=$matches[1]', 'top');
2
Answers
the code worked worked for me I have founf the smam etype of issue here
Example to add rewrite rule query as optional,hope it helps.
The main thing here is to add ? at the start of your regex. Like ?([^/]*)
Now, you can set a default value for the optional query where you will use the query.
Now you will get the same result for http://example.com/nutrition/strawberry or http://example.com/nutrition/