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 customizing another plugin by changing the rewrite rule, from:

    add_rewrite_rule('^api/auth/([0-9]+)?/?','index.php?__api=1&uid=$matches[1]','top');

to:

    add_rewrite_rule('^api/auth/','index.php?__api=1','top');

After making the change (and not forgetting to refresh the permalinks) my endpoint fails to work. When I attempt something like:

file_get_contents("http://mydomain.com/api/auth/")

...instead of the json object that should be returned, I get the user login form. enter image description here

What's even weirder is that when I add an integer to the end like this:

file_get_contents("http://mydomain.com/api/auth/3")

...I get the json object that I expect! What's going on here?

share|improve this question
1  
it would seem your rewrite hasn't flushed. there are plugins, like this one, that will let you see how the rules are being parsed. verify your rule is what you expect. –  Milo Jul 31 '12 at 1:44
    
That's a nifty plugin. However, it shows the newly updated rewrite rule. –  SDP Jul 31 '12 at 14:21

1 Answer 1

up vote 0 down vote accepted

So I've solved this problem, but I'm still scratching my head about the "solution":

add_rewrite_rule('api/autho/?$','index.php?__api=1','top');

This version of the rewrite rule works for some reason. I'm guessing that there's some sort of namespace conflict that I accidentally stumbled across. Maybe /auth/ is used somewhere else?

share|improve this answer

Your Answer

 
discard

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.