Server Fault is a question and answer site for system and network 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 need two urls to point to the same php file using nginx. How do I do this?

example: => /var/www/public_html/index.php/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 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


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

Browse other questions tagged or ask your own question.