Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nginx-重定向404 PHP文件_Php_Linux_Ubuntu - Fatal编程技术网

Nginx-重定向404 PHP文件

Nginx-重定向404 PHP文件,php,linux,ubuntu,Php,Linux,Ubuntu,我在我的本地电脑上使用拉威尔的代客泊车。我在我的本地电脑上对此没有问题。我的远程服务器使用ubuntu16.04 我的网站根目录中有一个类似的index.php: <?php require __dir__ . '/src/core/bootstrap.php'; require __dir__ . '/src/controllers/index.php'; 因此,当用户访问site.com时,它会转到main,因为它是主页。但是,比方说,他们访问:site.com/about,那么$

我在我的本地电脑上使用拉威尔的
代客泊车
。我在我的本地电脑上对此没有问题。我的远程服务器使用
ubuntu16.04

我的网站根目录中有一个类似的
index.php

<?php

require __dir__ . '/src/core/bootstrap.php';
require __dir__ . '/src/controllers/index.php';
因此,当用户访问
site.com
时,它会转到
main
,因为它是主页。但是,比方说,他们访问:
site.com/about
,那么
$page
将是
about
和viola。。。路由。这些都是在Laracasts上教给我的,所以如果这看起来。。。基本的

问题在于,当我访问
site.com/api
时,它只显示一个空白页面。或者,比如,
book?id=1
空白页。或

以下是
valet
中的
nginx
块,它告诉服务器如何处理未找到的文件:

location / {
    rewrite VALET_SERVER_PATH last;
}
如何将其应用到我的站点?我试着用
/var/www/html
替换
VALET\u SERVER\u路径
,但我刚得到一个服务器错误500

这是我当前的
nginx
块:

server {
    server_name www.site.org;
    return 301 $scheme://site.org$request_uri;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name site.org;
    return 301 https://$server_name$request_uri;
}

server {

    # SSL configuration
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;
    include snippets/ssl-site.org.conf;
    include snippets/ssl-params.conf;

    root /var/www/html;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name site.org;

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

    location ~ /.well-known {
        allow all;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
}

它起作用了。但只在头版。是的,我启用了HTTPS,并且
www
流量被重新定向到
非www
URI。

对以下指令进行更改:

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

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
}

嗯,怎么样。我知道发生了什么事——这起作用了!非常感谢。
location / {
    try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
}