From 33ff879d0db708375d5d4aebbea328b42cb2d213 Mon Sep 17 00:00:00 2001 From: Guilherme Nascimento Date: Tue, 14 May 2024 02:56:16 -0300 Subject: [PATCH] Updated NGINX instructions --- .htaccess | 3 +-- README.md | 37 ++++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.htaccess b/.htaccess index 17dedbb..277cae7 100644 --- a/.htaccess +++ b/.htaccess @@ -5,7 +5,6 @@ IndexIgnore * # Redirect page errors to route system -ErrorDocument 401 /index.php/RESERVED.TEENY-401.html ErrorDocument 403 /index.php/RESERVED.TEENY-403.html ErrorDocument 500 /index.php/RESERVED.TEENY-500.html ErrorDocument 501 /index.php/RESERVED.TEENY-501.html @@ -13,7 +12,7 @@ ErrorDocument 501 /index.php/RESERVED.TEENY-501.html RewriteEngine On # Ignore hidden files -RewriteRule (^\.|/\.) index.php [L] +RewriteRule ^\.|/\. index.php [L] # Redirect to public folder RewriteCond %{REQUEST_URI} !(^$|public/|index\.php(/|$)) diff --git a/README.md b/README.md index fb3173c..ac10fab 100644 --- a/README.md +++ b/README.md @@ -72,29 +72,36 @@ For NGINX you can use [`try_files`](https://nginx.org/en/docs/http/ngx_http_core ``` location / { - root /home/foo/bar/teeny; - index index.html index.htm index.php; + # Redirect page errors to route system + error_page 403 /index.php/RESERVED.TEENY-403.html; + error_page 500 /index.php/RESERVED.TEENY-500.html; + error_page 501 /index.php/RESERVED.TEENY-501.html; + + try_files /public$uri /index.php?$query_string; + + location = / { + try_files $uri /index.php?$query_string; + } location ~ /\. { - return 404; + try_files /index.php$uri /index.php?$query_string; } location ~ \.php$ { - fastcgi_pass 127.0.0.1:9000; # Replace by your FastCGI or FPM + # Replace by your FPM or FastCGI + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SCRIPT_NAME $fastcgi_script_name; - include fastcgi_params; - } + include fastcgi_params; - # Redirect page errors to route system - error_page 401 /index.php/RESERVED.TEENY-401.html; - error_page 403 /index.php/RESERVED.TEENY-403.html; - error_page 404 /index.php/RESERVED.TEENY-404.html; - error_page 500 /index.php/RESERVED.TEENY-500.html; - error_page 501 /index.php/RESERVED.TEENY-501.html; + set $teeny_suffix ""; + + if ($uri != "/index.php") { + set $teeny_suffix "/public"; + } - try_files /public/$uri /index.php; + fastcgi_param SCRIPT_FILENAME $realpath_root$teeny_suffix$fastcgi_script_name; + } } ```