Access Restriction .htaccess Generator
Access Restriction Examples
Remember you should turn on the rewrite first using
RewriteEngine on.
Deny Access from Specific IP
Order allow,deny
Deny from 123.45.6.7
Deny from 10.10.20.30
Allow from all
Deny Access from Specific Host
Order allow,deny
Deny from www.badhost.com
Deny from badhost23.com
Allow from all
Deny Access from Specific IP Range
Order allow,deny
Deny from 10.10.3.
Deny from 192.168.
Deny from 62.40.13.0/23
Deny from 10.40.34.0/255.255.255.0
Allow from all
Deny Access from such referers
This example is good to block such site that eating your bandwith.
RewriteCond %{HTTP_REFERER} baddomain0\.com [NC,OR]
RewriteCond %{HTTP_REFERER} baddomain1\.com
RewriteRule .* - [F]
Deny Access from bad spider bot
RewriteCond %{HTTP_USER_AGENT} ^Bot1 [OR]
RewriteCond %{HTTP_USER_AGENT} ^SpiderB [OR]
RewriteCond %{HTTP_USER_AGENT} ^RobotA
RewriteRule ^(.*)$ /deny.html
Allow from specific IP Address
Order deny,allow
Deny from all
Allow from 192.37.3.
Allow from .abc.com
Allow from www.google.com
Allow from 203.22.43.3