add_rewrite_rule not working in wordpress

I have an url like that http://localhost/leneufbreton/achat-immobilier-neuf/programme-neuf/?ville=brest and I want to transformed to that http://localhost/leneufbreton/achat-immobilier-neuf/programme-neuf/brest or that http://localhost/leneufbreton/achat-immobilier-neuf/programme-neuf-brest

I was trying to use add_rewrite_rule but nothing happend.
This is my code action that I used:

function custom_rewrite_basic() {
   add_rewrite_rule('^programme-neuf/([^/]*)/', 'programme-neuf/?ville=$matches[1]', 'top');

add_action('init', 'custom_rewrite_basic');

Any idea please ?.

Read more here: add_rewrite_rule not working in wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *