Created
September 3, 2022 06:52
-
-
Save finalwebsites/ce77b691730e4d3a0ff7884ef7e6b23c to your computer and use it in GitHub Desktop.
Ignore missing files and report a 404 status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!