Skip to content
Log In Sign Up info@muvcloud.com

What a 404 Error Means

404 Not Found means the server is reachable and answered, but no file or route matches the address. It says nothing about whether the page ever existed. A 410 Gone says the page was removed on purpose; a 301 sends visitors to a new address. Other codes are explained in HTTP status codes explained.

If You See It on Someone Else's Site

  • Check the address: look for typos, a missing letter, or extra characters copied with a link.
  • Go up one level: remove the last part of the address, or start from the home page and use the site's search.
  • Tell the site owner: if a link on their own site leads to the 404, they will want to know.

Find the Request in the Logs

sudo grep '" 404 ' /var/log/nginx/access.log | tail -20

Apache's access log is /var/log/apache2/access.log on Debian and Ubuntu and /var/log/httpd/access_log on AlmaLinux and Rocky Linux. Nginx also writes a line to /var/log/nginx/error.log with the full path it tried to open and the note "No such file or directory". That path is the fastest clue: if it is not where your files are, the configuration points to the wrong place.

Wrong Document Root or Server Block

sudo nginx -T | grep -nE 'server_name|root|listen'

Compare each root with the real folder. A request whose host name matches no server_name goes to the default server, often the distribution's welcome page, which returns 404 for your site's addresses. On Apache, sudo apache2ctl -S (Debian and Ubuntu) or sudo httpd -S (AlmaLinux and Rocky Linux) lists the virtual hosts and shows which one is the default.

Front Controllers and try_files

WordPress, Laravel, and most PHP frameworks send every address through index.php. Nginx has to be told to do that:

location / {
    try_files $uri $uri/ /index.php?$args;
}

Without the last part, every address that is not a real file on disk returns 404. For Laravel and Symfony, root must point to the public folder, not the project folder. Test with sudo nginx -t, then reload.

Apache Rewrite Rules

On Apache, the same job is done by rewrite rules in .htaccess. They are ignored unless the virtual host allows them:

<Directory /var/www/example.com>
    AllowOverride All
</Directory>

Rewrite rules also need mod_rewrite. Enable it with sudo a2enmod rewrite on Debian and Ubuntu; the default Apache package on AlmaLinux and Rocky Linux loads it already. Run sudo apachectl configtest and reload Apache.

Case-Sensitive Paths

Linux file systems treat About.html and about.html as two files. A site copied from a system that ignores case can work there and return 404 here. Find the real spelling:

find /var/www/example.com -iname 'about.html'

Rename the file or fix the link so both match exactly.

If the home page works and every post returns 404, the rewrite rules are missing. In the WordPress dashboard, open Settings, then Permalinks, and save without changes; WordPress writes its rules again, into .htaccess on Apache when it can write the file. With WP-CLI, wp rewrite flush rebuilds the rules stored in the database but does not touch .htaccess unless you add --hard. On Nginx there is no .htaccess: the try_files line above does the job.

A Custom 404 Page

Nginx and Apache each serve your own page for missing addresses:

error_page 404 /404.html;        # Nginx, in the server block
ErrorDocument 404 /404.html      # Apache, in the virtual host

Keep the status code 404. A page that says "not found" but returns 200 is a soft 404, and search engines may index it as content. For content that moved, send a 301 instead; avoid chains, as redirect loops show.

Confirm the Fix

curl -I https://example.com/blog/first-post/

The page should return 200, and a made-up address should still return 404. If the server now refuses the page with 403, see 403 Forbidden in Nginx.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations