Nginx 404 not found when trying to load files in the directory

CausingUnderflowsEverywhere

So I have a website.

www.example.com directory pointed at /var/www/html/

I can load a webpage at

www.example.com/foo/

The file for that page is at

/var/www/html/foo/index.html

that index.html has a style sheet and object in the foo folder and tries to request it using

www.example.com/foo/bar.css

However, bar.css returns 404 not found even though it's at

/var/www/html/foo/bar.css

What gives? The files have 644 user rights. If index.html can be found shouldn't the other files be too?

CausingUnderflowsEverywhere

Your folders must be set to file permission 755 using chmod. I successfully got it working after the following steps:

After changing the owner of foo/

$ /var/www/html# chown root foo

and the subfiles to root, as well as changing the chmod of foo/ to 755

chmod 755 foo

to mimic /var/www/html/ 's permissions, my files became accessible.

Remember to use

ls -l 

in your directory to check for the right file permissions. Also check your access and error logs at /var/log/nginx/ (this is accurate for debian at the very least, since this is what I am using)

If you can't find your log files, use

find / | grep error.log > results.txt

and open results.txt with your favourite text editor such as vi results.txt (Assuming you're on a server and it's easier to read text files than the terminal).

Thank you to Richard for telling me to check my logs.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

No such file or directory found when trying to load image from database?

Receiving 404 status when trying to load local files with NodeJS

nginx 404 Not Found for php files

Nginx Reverse Proxy on nixOS returns 404 when trying to load css/js

Failed to load resource: the server responded with a status of 404 (Not Found) when trying to fetch data from json

404 when trying to serve files from the filesystem

FileNotFoundError when trying to rename all the files in a directory

Static files 404 not found error with ssl - Django + uWSGI + nginx

Get Google.GoogleApiException 'File not found: [404]' when trying to list files in a non-root Google Drive folder

Forge / Nginx - 404 Not Found

NGINX htpasswd 404 not found

404 Not Found nginx React

Nginx File 404 when trying to launch drupal install.php

404 - File or directory not found

Getting 404 not found when trying to update data using a query in Django

Facing 404 page not found when trying to pass value in url in Codeighter

when trying to upload a file getting 404 not found error node js

404 Not Found Error when trying to display a chart with Chart.js

404 page not found when trying to use Gqlgen with julienschmidt/httprouter

Nginx returns 404 not found when access file on server

Get a 404 Not Found from nginx when ng build

Spring Boot 404 when trying to load a HTML file using Thymeleaf

404 Error when trying to load locale in Angular 5

"Class not found" when trying to use composer auto load for a wordpress plugin

"Class not found" when trying to use composer auto load in a wordpress plugin

Getting file not found error when trying to load eel.js

File not found error when trying to load Librosa's example file

ENOENT no such file or directory when trying to load ForerunnerDB with requirejs

Jenkins pipeline - No such file or directory when trying to load external groovy file