Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

How do I do this? This seems to work by default in apache, but not on nginx it appears?

share|improve this question

Sounds like you want something like this in your site config:

rewrite ^/(.+)$ /$1.php last; 

This would rewrite anything after the / to a php filename, though there are some cases I would think you'd not want that.

share|improve this answer

A better approach is probably the try_files directive (although this won't handle the /test/ case):

try_files $uri $uri.php?q=$uri&$args;
share|improve this answer
rewrite "^/test/?$" /test.php; 
share|improve this answer

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.