2

When I say 'not working' I don't mean it's broken. I mean I can't get it to work so I must be doing something wrong. (I am new to this)

I have the following code in a htaccess file placed in the folder I want to restrict access to...

<Limit GET>
Order deny,allow
Deny from all
Allow from [the ip address I'm trying to allow]
</Limit>

I have checked that the AccessFileName directive is set in apache2.conf

I reboot the server after each edit of the file.

The file is set with 644 permissions.

And I am still able to access the site from ips other than the one I'm allowing.

What am I doing wrong?

3
  • Could you self-answer the question? Instead of using "solved" in the title you could accept the answer so the Q/A structure is maintained.
    – Nanne
    Oct 27, 2012 at 12:38
  • I'll do that. I did it the way I did because I've often seen it done that way.
    – MrVimes
    Oct 27, 2012 at 12:40
  • If all goes rite, not on "stackexchange" sites. Anyway, +1 for you answer :)
    – Nanne
    Oct 27, 2012 at 12:53

1 Answer 1

3

After some googling I found out that in order for htaccess files in folders other than the root to be taken into account by the server, the directive 'AllowOverride' needs to be set to 'All' for that site in /etc/apache2/sites-available/ (in my case the default site)

There may be other ways to acheive the same result but this is the one I found.

2
  • Apache didn't like it when I added AllowOverride to my site in the sites-available directory. "AllowOverride not allowed here". Apache wouldn't start. Mar 10, 2013 at 9:50
  • Did you put <limit>...</limit> inside /etc/apache2/sites-available/default file ?
    – nunu
    Nov 1, 2017 at 4:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .