Support » Developing with WordPress » Unwanted redirect due to rewrite rule

  • If i go to /itinerary/armenie-8-dagen-individuele-reis/test the following happens (inspector tools):

    Request:
    Request URL: http://rosettalocal.nl/itinerary/armenie-8-dagen-individuele-reis/asdasd
    Request Method: GET
    Status Code: 301 Moved Permanently
    Response:
    Location: http://rosettalocal.nl/itinerary/armenie-8-dagen-individuele-reis/
    X-Redirect-By: WordPress

    Functions.php:

    
    function custom_rewrite_tag() {
        add_rewrite_tag('%blaat%', '([^&]+)');
    }
    add_action('init', 'custom_rewrite_tag', 10, 0);
    
    function add_query_vars($aVars) {
        $aVars[] = "blaat"; // represents the name of the product category as shown in the URL
        return $aVars;
    }
    add_filter('query_vars', 'add_query_vars');
    
    function add_rewrite_rules()
    {
        add_rewrite_rule('^itinerary/armenie-8-dagen-individuele-reis/([a-zA-Z0-9_]+)/?', 'index.php?page_id=1809&blaat=$matches[1]', 'top');
        flush_rewrite_rules(true);
    }
    
    add_action("init","add_rewrite_rules");
    

    My lat url part is gone and if in my template i use, i get “false”:

    
        var_dump(get_query_var('blaat', false));
    

    What i want is that the url stays:
    itinerary/armenie-8-dagen-individuele-reis/test

    And that the following page is fetched, and i have access to blaat variable:
    index.php?page_id=1809&blaat=test

    I’m using wp-travel.

    What am i doing wrong?

    • This topic was modified 5 months, 3 weeks ago by ivaralink.
    • This topic was modified 5 months, 3 weeks ago by ivaralink.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.