Skip to content

Instantly share code, notes, and snippets.

@TechRemarker
Created February 15, 2012 00:19
Show Gist options
  • Save TechRemarker/1831978 to your computer and use it in GitHub Desktop.
Save TechRemarker/1831978 to your computer and use it in GitHub Desktop.
IP Restrict a Domain or Subdomain

IP Restrict a Domain or Subdomain

Create a .htaccess file. (they are hidden by default)

Add the following contents:

Deny from all Allow from 0.0.0.0.0

(Replace 0's with your IP to allow. Add as many Allow from lines as needed)

This will affect all subdirectories, unless a subdirectory has .htaccess that overrides this.

So http://example.com can be viewable to the public, but if you add the above .htaccess to http://dev.example.com it will block that page from the general public.

Will only block on port 80, will not block FTP or SSH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment