设置nginx默认路径和路由

时间:2017-03-10 04:09:08

标签: php 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.

有人可以帮助我吗?先谢谢。

1 个答案:

答案 0 :(得分:1)

ptr.pointee消息由Passing Uncontrolled Requests to PHP引起。

如果您希望URI No input file specified访问/路径,请执行重定向:

/v1/

在上面的例子中,我删除了一些没有执行任何功能的位置块。

相关问题