2017-03-10 267 views
1

我在网上搜索了很长时间。但没用。请帮助或尝试提供一些想法如何实现这一点。 我有一个nginx服务,它有一些项目,当我使用这个配置时,它可以很好地工作。设置nginx默认路径和路由

#user nobody; 
worker_processes 1; 

events { 
    worker_connections 1024; 
} 
http { 
    include  mime.types; 
    default_type application/octet-stream; 


sendfile  on; 



keepalive_timeout 65; 

server { 
    listen  80; 
    server_name localhost; 

    #charset koi8-r; 

    #access_log logs/host.access.log main; 
    root   html; 
    ***location /v1/ { 
     alias html/v1/; 
     index index.html index.htm index.php; 
    }*** 
    location /v2/ { 
     alias html/v2/; 
     index index.html index.htm index.php; 
    } 
    location /mch/ { 
     alias html/mch/; 
     index index.html index.htm index.php; 
    } 
    location /user/ { 
     alias html/user/; 
     index index.html index.htm index.php; 
    } 
    location /merchant/ { 
     alias html/merchant/; 
     index index.html index.htm index.php; 
    } 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root html; 
    } 
    location ~ \.php$ { 

     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include  fastcgi_params; 
    } 


} 





} 

然后我想设置的默认路径v1.I改变这样的配置:

location/{ 
     alias html/v1/; 
     index index.html index.htm index.php; 
    } 

它的工作错了白衣这样的错误:

No input file specified. 

别人的帮助我?提前致谢。

+0

您可以指定在执行'localhost/v1'时要执行哪个文件吗? –

回答

1

No input file specified消息是由Passing Uncontrolled Requests to PHP引起的。

如果你想在URI /访问/v1/路径,执行重定向:

server { 
    listen  80; 
    server_name localhost; 

    root html; 
    index index.html index.htm index.php; 

    location =/{ 
     return 302 /v1/; 
    } 

    error_page 500 502 503 504 /50x.html; 

    location ~ \.php$ { 
     try_files $uri =404; 

     include  fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $request_filename; 
     fastcgi_pass 127.0.0.1:9000; 
    } 
} 

在上面的例子中,我已经删除了未执行任何功能的某个位置块。

+0

非常感谢。 – alphayan