#server { # listen 80; # server_name laravel.com.co; # return 301 https://laravel.com.co$request_uri; #} server { listen 80; listen [::]:80; server_name xxx.com; location /assets { alias /var/www/xxx/public/assets; } root /var/www/xxx/public; index index.php index.html index.htm; #关键的地方 if (!-e $request_filename) { rewrite ^(.+?\.php)(/.+)$ /$1?s=$2 last; rewrite ^/(.*)$ /index.php?s=$1 last; break; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_pass php-upstream; fastcgi_index index.php; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fixes timeouts fastcgi_read_timeout 600; include fastcgi_params; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; } location ~ /\.ht { deny all; } location /.well-known/acme-challenge/ { root /var/www/letsencrypt/; log_not_found off; } error_log /var/log/nginx/laravel_error.log; access_log /var/log/nginx/laravel_access.log; }