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)(/.+)$;
}