Forum Moderators: bakedjake

Message Too Old, No Replies

Blocking all ip's but my own

         

rfontaine

3:26 pm on Dec 5, 2005 (gmt 0)

10+ Year Member



I am creating a new website and want to block every ip address but one (my own) in .htaccess.

What is the best way to do this?

Span

6:07 pm on Dec 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not saying that this is the best way to do it, but it should work.


RewriteEngine On
RewriteCond %{REMOTE_ADDR}!^22\.33\.44\.55$
RewriteRule .* - [F]

Reads like: IF the visitor's IP address not matches "22.33.44.55", THEN serve a 403.

rfontaine

6:28 pm on Dec 5, 2005 (gmt 0)

10+ Year Member



Hmmm...

Throws an Internal Server Error - but I know RewriteEngine On works

Span

7:11 pm on Dec 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's been a while since I posted here, so obviously I forgot to say there must be a space before the exclamation mark:

RewriteCond %{REMOTE_ADDR} !^22\.33\.44\.55$

Could it be that?

rfontaine

7:25 pm on Dec 5, 2005 (gmt 0)

10+ Year Member



Yes Span, you fix the error. Thank you very much!

LeChuck

8:23 pm on Dec 6, 2005 (gmt 0)

10+ Year Member



Or you could do

Order deny,allow
deny from all
allow from 100.100.100.100

in .htaccess

No need for mod rewrite.