我在开发和生产中都使用了相同的nginx配置,并且生产服务器不断将资产链接(仅资产链接)重定向到主页。刀片视图路线提供的其他链接也可以。
只要在Laravel的路线上有一个视野,到https://subdomain.example.com/test
的链接就可以正常工作。
但是,指向https://subdomain.example.com/img/picture-of-a-cat.png
的链接将被重定向回主屏幕,但地址栏仍将显示https://subdomain.example.com/img/picture-of-a-cat.png
。仅在生产中观察到此行为。
服务器详细信息:Ubuntu 18.4,Nginx,Laravel最新
渔获物在哪里?
生产配置:
server {
listen 80;
listen [::]:80;
server_name subdomain.example.com
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name subdomain.example.com;
root /var/www/html/public;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
ssl_certificate /etc/ssl/certs/example-cert.cer;
ssl_certificate_key /etc/ssl/private/example-private-key.key;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
}