From e08f08e1ace2a3b09cb67b5921228ce28de1ef4f Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 12 Jul 2021 22:47:43 +0200 Subject: [PATCH] Improve nginx.conf to avoid ?q= at the end of some URLs --- conf/nginx.conf | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b18ebe0..a467dc9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -3,10 +3,6 @@ location __PATH__/ { alias __FINALPATH__/; index index.php; - if (!-e $request_filename) - { - rewrite ^(.+)$ __PATH__/index.php?q=$1 last; - } if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } @@ -20,8 +16,11 @@ location __PATH__/ { more_set_headers "X-Download-Options: noopen"; more_set_headers "X-Permitted-Cross-Domain-Policies: none"; - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; + # Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 ) + try_files $uri $uri/ __PATH__/__PATH__/index.php?$query_string; + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params;