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 install nginx 1.0.0 and i installed it /usr/local/nginx1.0.0/. and I try to modify /usr/local/nginx1.0.0/cont/nginx.conf file.

I just copy default file. and replace server_name and root path

and I connected example.com -> it works (there is nginx working message.)

but I connected www.example.com -> it is not working.(there is 404 Not Found message.)

and url is = http://www.example.com/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/

and I try to server_name => example.com *.example.com (but same problum)

this is my nginx.conf code. am i wrong config? or wrong install?

server {
        listen       80;
        server_name  .example.com;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

      location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  html$fastcgi_script_name;
            include        fastcgi_params;
        }

        location ~ /\.ht {
            deny  all;
        }
    }
share|improve this question
add comment

1 Answer 1

Do you have any other server {} blocks that might have a better match for www.example.com and override this block?

Also, you probably don't want to use fastcgi_index. It's only useful in a few unusual circumstances. For the typical case like you have, you want to use something like

try_files $uri $uri/index.html $uri/index.htm $uri/index.php

in your location / {} block. The last item generates an internal redirect to the location ~ \.php$ {} block.

share|improve this answer
    
Just FYI, $uri/ in try_files will apply your index directive as well, so you don't need to specify all the index files. Plus, your last argument to try_files must be a guaranteed file or a named location. –  Martin Fjordvald Apr 17 '11 at 23:00
    
thnak you friends!!! I solved it after your advice! –  artworker Apr 18 '11 at 0:42
    
I make 2 servers 1. www.example.com 2. *.example.com and i redirect *.example.com -> www.example.com and i add try_files it works greatfully! –  artworker Apr 18 '11 at 0:47
add comment

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.