【发布时间】:2019-08-11 19:35:03
【问题描述】:
我正在使用宅基地(所以我处理 Nginx)并且我想匹配一些可以包含“.php”的路由。 我的 nginx 配置文件:
server {
listen 80;
listen 443 ssl http2;
server_name .homestead.test;
root "/home/vagrant/code/test/public";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
add_header 0 false;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/homestead.test-error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.3-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;
}
ssl_certificate /etc/nginx/ssl/homestead.test.crt;
ssl_certificate_key /etc/nginx/ssl/homestead.test.key;
}
我想并且我希望它与 nginx 设置有关。因为我遵循了这个解决方案https://laracasts.com/discuss/channels/general-discussion/routes-with-php-file-extensions,我几乎让它工作了,但不是我想要的确切方式(在 URL 之前没有那个“配置”)
【问题讨论】:
标签: php laravel nginx nginx-config