while trying to setup a 404 webpage on one of my sites I couldn't find a solution for non-existing links containing a slash, for instance if i try to connect to https://supra.tf/anything
, it will return a correct page, but after trying https://supra.tf/anything/anything
correct page is being returned, but with no formatting (aka css/js files). This is my nginx config:
root /var/www/supra.tf/public_html;
index index.html;
server_name supra.tf;
error_page 404 /404.html;
location / {
rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent;
rewrite ^/(.*)/$ /$1 permanent;
try_files $uri/index.html $uri.html $uri/ $uri =404;
}
location = /404.html {
root /var/www/errors;
}
location ~* ^.+\.(js|css|img)$ {
root /var/www/errors;
try_files $uri/index.html $uri.html $uri/ $uri =404;
}
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
listen [::]:443 ssl http2 ipv6only=on; # managed by Certbot
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/supra.tf/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/supra.tf/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
listen 80;
listen [::]:80;
server_name supra.tf;
return 301 https://supra.tf$request_uri;
}
What could be a problem here?