Secure access to single file by IP
1 2 3 4 5 |
<Files filename> Order Deny,Allow Deny from All Allow from YourIP </Files> |
Secure access to a whole directory of files
1 2 3 4 5 |
<FilesMatch ".*"> Order Deny,Allow Deny from All Allow from YourIP </FilesMatch> |
Secure a single file with a Basic Login
1 2 3 4 5 6 |
<Files filename> AuthName "Admin-Section" AuthType Basic AuthUserFile .htpasswd require valid-user </Files> |
Secure multiple files and deny access
1 2 3 4 |
<FilesMatch "(.htaccess|.htpasswd|filename.php|readme.html)"> order deny,allow deny from all </FilesMatch> |
Allow only some files to be accessed
1 2 3 4 5 |
order deny,allow deny from all <files ~ ".(xml|css|jpe?g|png|gif|js)$"> allow from all </files> |
Prevent directory browsing
1 |
Options All -Indexes |
Disable hotlinking
1 2 3 4 |
RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?YourDomain [NC] RewriteRule .(jpg|jpeg|png|gif)$ - [NC,F,L] |