Skip to content

Instantly share code, notes, and snippets.

@finalwebsites
Created September 3, 2022 06:52
Show Gist options
  • Select an option

  • Save finalwebsites/ce77b691730e4d3a0ff7884ef7e6b23c to your computer and use it in GitHub Desktop.

Select an option

Save finalwebsites/ce77b691730e4d3a0ff7884ef7e6b23c to your computer and use it in GitHub Desktop.
Ignore missing files and report a 404 status
# add this code to your .htaccess file (Apache based servers only)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|png|gif|bmp|ico|css|js|swf|htm|html|txt|php|asp|aspx)$ [NC]
RewriteRule .* - [L,R=404]
</IfModule>
@finalwebsites
Copy link
Author

finalwebsites commented Mar 2, 2025

Use this code if your web server is based on NGINX:
location ~* \.(gif|jpg|jpeg|png|css|js|svg|txt|zip|html|json|aspx|xml)$ { error_page 404 /404.html; expires max; access_log off; }
Don't forget to create the static 404.html file!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment