I am developing quiz section for my wordpress site. I have W3 total cache installed on my site.
I want to put quiz on
http://www.example.com/quiz/seo-friendly-title/id
and rewrite htaccess to redirect the url to
http://www.example.com/quiz?title=seo-friendly-title&quiz-id=id
The quiz section is developed as wordpress template and a blank page is made using this template.
This is .htaccess I wrote.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^quiz/([\w\d\-]+)/(\d]+)$ quiz?title=$1&quiz-id=$2 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any form of help would be appreciated!
You can try this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^quiz/seo-friendly-title/(.*)$ quiz?title=seo-friendly-title&quiz-id=$1 [R,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Did you go to settings and permalinks? if yes and its not what you want have a look here
how to hide a page from being seen in wordpress backend and frontend
add_action('init', 'a_add_rewrite_rule');
function a_add_rewrite_rule(){
// add_rewrite_rule(REGEX url, location, priority (i.e. top is before other rewrite rules)
// I created a custom post type for this plugin called market -- replace post_type with whatever you want
//basically tell wordress to add a query var if sidebar is added to url.
add_rewrite_rule('^sidebar?','index.php?is_sidebar_page=1&post_type=market','top');
}
// register a query var
add_action('query_vars','market_set_query_var');
function market_set_query_var($vars) {
array_push($vars, 'is_sidebar_page');
return $vars;
}
// associate a template with your quer_var
add_filter('template_include', 'market_include_template', 1000, 1);
function market_include_template($template){
if(get_query_var('is_sidebar_page')){
$new_template = (theme or plugin path).'/pages/yourpage.php'; // change this path to your file
if(file_exists($new_template))
$template = $new_template;
}
return $template;
}