Nginx 如何将我的主页和HTML文件以及所有其他路径/URL与PHP文件连接起来

Nginx 如何将我的主页和HTML文件以及所有其他路径/URL与PHP文件连接起来,nginx,nginx-location,Nginx,Nginx Location,我试图实现的是,如果有人访问我的主页/索引页面,我需要为我的index.html文件提供服务器。但是,如果是另一个URL/路径,请将请求传递到我的index.php文件(我使用的是Symfony) 我跟着,但不工作。它总是为我的PHP文件服务 server { listen 80; server_name mysite.com; root /path/to/my/web; index index.html index.php; loc

我试图实现的是,如果有人访问我的主页/索引页面,我需要为我的
index.html
文件提供服务器。但是,如果是另一个URL/路径,请将请求传递到我的
index.php
文件(我使用的是Symfony)

我跟着,但不工作。它总是为我的PHP文件服务

server 
{
    listen       80;
    server_name mysite.com;

    root   /path/to/my/web;
    index index.html index.php;

    location = /index.html 
    {
        try_files $uri /index.html?$args;
    }

    location / 
    {
        try_files $uri /index.php?$args;
    }

}

我将非常感谢您能与我分享的任何帮助或指导。

这终于对我起到了作用:

server 
{
    listen       80;
    server_name mysite.com;

    root   /path/to/my/web;
    index index.html index.php;

    location = / 
    {
        try_files $uri /index.html?$args;
    }

    location / 
    {
        try_files $uri /index.php?$args;
    }

}