Question

I have a .htaccess file that limits the access of my website to an IP range. I do it like that :

# Limite access to 160.98.xxx.xxx
<Limit GET POST>
    order deny,allow
    deny from all
    allow from 160.98.
</Limit>

But I have a "Forbidden You don't have permission to access /testip/test.txt on this server." when I tried to access it with my IP that actually begins with 160.98.

Am I doing it something wrong with the .htaccess ? It is located to the root of the website. I have generated the code of the .htaccess with http://www.toshop.com/htaccess-generator.cfm

Was it helpful?

Solution

According to your comment above you request with a local address, not with the one you expected. So you have to grant access to that address to:

# Limite access to 160.98.xxx.xxx
<Limit GET POST>
    order deny,allow
    deny from all
    allow from 160.98.
    allow from 127.0.
</Limit>

Most likely that is not your ultimate goal, but it answers the question. If you want to test if the specified address range starting with 160.98. has access, then you have to make a request from such an address. Currently you don't, since obviously you test from the same system which will always use the loopback address.

OTHER TIPS

Removing the last . should fix it.

# Limite access to 160.98.xxx.xxx
<Limit GET POST>
    order deny,allow
    deny from all
    allow from 160.98
</Limit>

im no expert but doesn't having the 'deny from all' conflict with what your doing, shouldn't you only be listing the allow from in their? i'd expect their might be some kind of exept command to go along with the deny all, , plus shouldn't you be listing the full 127.0.0.1 instead of just 127.0. wouldn't this confuse it? like i say im no expert but that was my first thought when looking.

Im still trying to figure out if i can use a * symbol after the . in an IP to block any number after the dot. I want to block IP ranges and would have liked to have just put a - sign between the range but from what im reading on this site i have to do it some other way. im still reading for the answer! i want to stick a block list from a site lick spamhaus to block all baddies!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top