1. 程式人生 > >nginx伺服器除了根目錄可以訪問,其他都出現404

nginx伺服器除了根目錄可以訪問,其他都出現404

  listen        80;
  server_name   www.hongtaofei.com;

  location / {
        root    /home/www/shop/public;
        index  index.html index.htm index.php;

         try_files $uri $uri/ /index.php?$query_string;
         if (!-e $request_filename){
             rewrite ^/(.*) /index.php last;
         }
  }

  location ~ \.php$ {
    root    /home/www/shop/public;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
    include        fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}
自己寫的配置檔案的話,需要加上標紅的程式碼就可以了