Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to do some url rewriting. I've picked this example right off the wordpress wiki here:

add_rewrite_rule('^nutrition/([^/]*)/([^/]*)/?','index.php?foo=bar','top');

The wiki page says:

This example would match a requested URL like this: example.com/nutrition/milkshakes/strawberry/ ...and interpret it to actually mean...
example.com/index.php?page_id=12&food=milkshake&variety=strawberry

(I've simplified it to redirect to index.php?foo=bar ). However, I'm still getting a 404 error when I try to visit http://localhost/myblog/nutrition/milkshakes/strawberry/. What am I doing wrong?

share|improve this question
    
what is your actual, not simplified rewrite rule? you have to load a WordPress object- a page, a post, an archive, etc.. You can't just set arbitrary non-existent query vars. –  Milo Nov 15 '13 at 2:23
    
@Milo My line for setting the url is exactly as i gave, index.php?foo=bar –  Click Upvote Nov 15 '13 at 2:48
    
did you add the rule on the init action? have you flushed rewrite rules by visiting the permalinks settings page? –  Milo Nov 15 '13 at 3:22

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.