• Hi Guys,

    Want something pretty simple, basically wanna redirect every page to the index.php so i can dynamically load it there. So added this to my function.php

    add_filter('rewrite_rules_array', 'slug_rewrite_rules_flush');
    
    function slug_rewrite_rules_flush($rules) {
    
    	$newrules = array();
    
    	$new_rules['(.*)/?$'] = 'index.php?test=test';
    
    	return $new_rules+$rules;
    }

    No problem, worked fine. However, I also want to be able to use the test variable I’m sending along. So added a query_vars hook.

    add_filter('query_vars','slug_rewrite_vars');
    
    function slug_rewrite_vars($vars) {
    
    	$vars[] = 'test';
    
    	return $vars;
    }

    Problem is that when I add this, I get a totally white page, not errors, nothing. When I change ‘test’ inside the slug_rewrite_vars function to anything not related to test. So for example:

    add_filter('query_vars','slug_rewrite_vars');
    
    function slug_rewrite_vars($vars) {
    
    	$vars[] = 'ChangedThisVariable';
    
    	return $vars;
    }

    …then it works again, but of course I cannot $_GET the test variable. Anyone knows what I’m doing wrong?

  • The topic ‘query_vars crashes rewrite_rules_array’ is closed to new replies.