Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need two urls to point to the same php file using nginx. How do I do this?

example:

api.example.com/users => /var/www/public_html/index.php/users
example.com/api/users => /var/www/public_html/index.php/users

I'm trying:

location ~ ^/api/(.*)$ {
   try_files $uri $uri/ /index.php?$1;
}

This adds '/api/' to the request url. How can this be prevented?

share|improve this question
    
any reason not to do this on the back end by creating a softlink for the directory? –  TheFiddlerWins Sep 11 '13 at 18:34
    
I'm using api.example.com for firefox and other webkit browsers. I wasn't able to use that url in IE9 because of some of the CORS restrictions. So now I'm trying it this way. –  Boedy Sep 11 '13 at 18:40
    
Is that a typo? You have $s1 instead of $1. –  Michael Hampton Sep 11 '13 at 19:39
    
Yes, That's a typo. Thanks –  Boedy Sep 11 '13 at 21:08

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.