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

So essentially I'm currently facing a problem with getting the following to work.

I've tried various methods of try_files, but none of them seem to be working. The above is literally all I need to be able to do, but this is the error that I'm coming up with:

Here is a copy of my current config.

            server {
                listen          80;
                server_name     example;
                error_log       /var/log/nginx/error.log;

                index           index.php;
                root            /www/;

                location / {
                    try_files $uri $uri/ /index.php =404;

                location ~* \.php$ {
                    include fastcgi_params;

I've tried a lot of combinations I've read from various tutorials for the try_files in location / and none of them have worked in the way that I've wanted. I've either got a 404 (if index.php isn't included in the end, because it's not finding the file or a directory) or a 500 error.

2013/01/23 07:21:35 [error] 1411#0: *1 rewrite or internal redirection cycle while internally redirecting to "/testing_nginx.php/test", client:, server: subeta, request: "GET /testing_nginx.php/test HTTP/1.1", host: ""
share|improve this question
Why do you want url.php in your URLs to begin with? Using it is a kludge for crappy web servers that don't have rewrites and things like try_files. Remove it. – Michael Hampton Jan 23 '13 at 7:47

You can use Nginx URL Rewriting. By instance can add this to your nginx.conf.

location / {
  rewrite  ^/pay/(.*)/(.*)$     /pay.php?p=$1&s=$2?   last;
  rewrite  ^/register$          /register.php?        last;

  location ~ \.ph[pb]$ {
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.