custom htaccess rewrite rule for page

You can do this with WordPress’ built-in rewrite system.

function add_video_rewrite() {
    add_rewrite_tag("%video_id%", '([^/]*)');
    add_rewrite_tag("%video_src%", '([^/]*)');
    add_rewrite_tag("%video_title%", '([^/]*)');
    add_rewrite_rule('^video/([^/]*)/([^/]*)/[^/]*)', 'index.php?pagename=video&video_id=$matches[1]&video_src=$matches[2]&video_title=$matches[3]', 'top');
}
add_action( 'init', 'add_video_rewrite' );

Didn’t test it, but I think this should work.
What is does is first adding tags that you can use in your template (get_query_var(video_id)). Then add a rewriterule that specifically matches the URL.

You should put this code in your functions.php and then flush your rewriterules (go to setting > permalinks).

More info about rewriterules for WordPress:
http://codex.wordpress.org/Rewrite_API
http://codex.wordpress.org/Rewrite_API/add_rewrite_tag
http://codex.wordpress.org/Rewrite_API/add_rewrite_rule

Leave a Comment