404 not found - broken links to CSS, images

后端 未结 2 1965
情书的邮戳
情书的邮戳 2020-12-21 13:46

I am experiencing a strange problem regarding broken links to the CSS and image files.

On our website everything works as expected. If you type in a non existing UR

2条回答
  •  无人及你
    2020-12-21 14:20

    In my case, there were already location blocks in my conf file for the files suffering from broken links, the blocks just weren't configured properly.

    Here's what I ended up with in my default.conf. For all URIs ending in "/sad.svg", it serves the file at the specified directory, ignoring any path earlier in the URI.

    ...
      error_page 404 /404.html;
      location = /404.html {
              root /var/www/errors;
              internal;
      }
    
      location ~* ".*/sad.svg"  {
          alias /var/www/errors/sad.svg;
          access_log off;
      }
      location ~* ".*/twitter.svg" {
          alias /var/www/errors/twitter.svg;
          access_log off;
      }
      location ~* ".*/gitlab.svg" {
          alias /var/www/errors/gitlab.svg;
          access_log off;
      }
    ...
    

提交回复
热议问题