Logo

Using Htaccess to Restrict Access by IP

Posted Tuesday, September 28, 2021 ( 2 months ago)

Last updated: October 16th, 2021

order deny,allow
deny from all
allow from  

Restrict access from specific IP addresses

deny from 173.236.241.

Allowing access from a specific IP

order deny,allow
deny from all
allow from 

Restrict  access from a specific domain

SetEnvIfNoCase Referer "example.com" bad_referer
Order Allow,Deny
Allow from ALL
Deny from env=bad_referer

This denies entrance to anyone who links to the site from www.example.com. If someone clicks on the link at example.com that redirects to your site, then they see a 403 Forbiddance error.