I am trying to rewrite rule to seo friendly. Here is the code I put in my theme function.php
add_action('init', 'add_my_rewrite_rule');
function add_my_rewrite_rule(){
add_rewrite_rule('^quiz/([^/]*)/([^/]*)?','index.php?pagename=quiz&quiztitle=$matches[1]&quizid=$matches[2]','top');
}
add_filter('query_vars','set_quiz_query_var');
function set_quiz_query_var($vars) {
array_push($vars, 'quiztitle');
array_push($vars, 'quizid');
return $vars;
}
Because this snippet didn't work, I also tried to rewrite .htaccess rule.
RewriteRule ^quiz/([^/]+)/([^/]+)$ /index.php?pagename=quiz&quiztitle=$1&quizid=$2 [NC,R=301,L]
I guess this is because of w3 total cache. I spent whole night but couldn't figure it out alone....