i have a page in wordpress called "video". its page id is 6, and its slug is "video"

in my theme ive set it up to show content based on GET variables

here is the URL rewrite im trying to set up:

heres the original URL with the GET variables inside:


heres the URL i want it rewritten to so it can be indexed:


heres my htaccess file that is not working:

# BEGIN WordPress
<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^video/(.*)/(.*)/(.*)$ ?page_id=6&7video_id=$1&video_src=$2&video_title=$3 [NC]
# END WordPress

what happens is, when i try and visit mysite.com/video/102230/MTAyMjMw/FC+Emmen+v+AGOVV+Apeldoorn, it simply automatically goes to mysite.com/video and removes everything after /video

edit - now it is not removing everything after /video, but its telling me "Nothing found for Video 102230 MTAyMjMw FC+Emmen+v+AGOVV+Apeldoorn"

1 Answer 1


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

  • ok its not giving me the "page not found" anymore, however when i do print_r($_GET) it echos an empty array.
    – scarhand
    Jan 21, 2012 at 14:50
  • Yes you can get the var with get_query_var("video_id") get_query_var("video_src") get_query_var("video_title") Jan 21, 2012 at 15:06
  • can you help me with this topic: wordpress.stackexchange.com/questions/39708/…
    – scarhand
    Jan 21, 2012 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.