Skip to content

Instantly share code, notes, and snippets.

@chris-carneiro
Last active August 9, 2017 09:22
Show Gist options
  • Save chris-carneiro/b74c433841b1afbeaa45e00be9c3da12 to your computer and use it in GitHub Desktop.
Save chris-carneiro/b74c433841b1afbeaa45e00be9c3da12 to your computer and use it in GitHub Desktop.
.htaccess that makes apache return "not found" for requests that either lead to a 404 or 403.
ErrorDocument 404 "Not found" Or http://yourdomain.com ## Redirects 404 Error to home page
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/(.*)$ - [R=404,L] ## Returns Error 404 when trying to access a subfolder
## Returns 404 when trying to access the current .htaccess file
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.(htpasswd|htaccess|aahtpasswd).*\ HTTP/ [NC]
RewriteRule .? - [R=404,NS,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment