tags:

views:

29

answers:

1

Hello, i added this code to .htaccess and place it the root of my website: $allowed[0]="xxx.xxx.xxx.xxx"; $allowed[1]="yyy.yyy.yyy.yyy";

// add as many as you need

if (!in_array($_SERVER['REMOTE_ADDR'],$allowed)) header("HTTP/1.1 403 Forbidden");

?>

but it's seems it doesn't work, I'm getting server error page

can you please tell me what i did wrong?

Thank you

+3  A: 

Get rid of it. That's PHP code, .htaccess is for Apache code/syntax. I think you want something like:

<Limit GET POST>
Order Deny,Allow
Deny from All
Allow from 69.20.39.30
</Limit>

Specify the IPs that you want, assuming this is some sort of restricted area.

meder
Why would you only want to limit GET and POST?
That's just the first thing that popped in my head as it's the syntax I have used thus far. Would you not rely on the Limit directive and just have the Order/Deny/Allow straight up in the .htaccess or does it need to be contained in some directive?
meder