nginx version: nginx/1.18.0
This is my 'nginx' conf default 'vhost':
cat /etc/nginx/sites-enabled/000-default
server {
listen 80;
listen [::]:80;
server_name example.org;
return 301 https://$server_name$request_uri;
}
# HTTPS
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
index index.html;
server_name example.org www.example.org;
root /home/www/example.org;
include /etc/nginx/ssl.conf;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
}
location / {
# rewrite foobar.html to foobar, foobar.php to foobar
if ($request_uri ~ ^/(.*)\.html$) { return 302 /$1; }
try_files $uri $uri/ $uri.html $uri.php?$args;
}
error_page 500 502 503 504 /50x.html;
error_page 404 /404.html;
location = /50x {
root /home/www/example.org;
# rewrite foobar.html to foobar, foobar.php to foobar
if ($request_uri ~ ^/(.*)\.html$) { return 302 /$1; }
try_files $uri $uri/ $uri.html $uri.php?$args;
}
location = /404 {
root /home/www/example.org;
# rewrite foobar.html to foobar, foobar.php to foobar
if ($request_uri ~ ^/(.*)\.html$) { return 302 /$1; }
try_files $uri $uri/ $uri.html $uri.php?$args;
}
access_log /var/log/nginx/example.org.access.log;
}
I have both '404.html' and '50x.html' files in my root directory.
If I call them directly, It's a success, but if I try to get an unknown page like https://example.org/non-existant, I get File not found
string instead of my HTML page.
Any help?
TIA