2017-03-10 266 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