WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"

share|improve this question
up vote 1 down vote accepted

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

share|improve this answer
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 '12 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") – Rob Vermeer Jan 21 '12 at 15:06
can you help me with this topic: wordpress.stackexchange.com/questions/39708/… – scarhand Jan 21 '12 at 22:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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