.htaccess allow from hostname?

Ubuntu 9.10 Apache2

Hi Guys,

Long story short, I need to restrict access to a certain part of my web site based on a dynamic IP source address that changes every now and then. Historically, I've just added the following to htaccess...

order deny,allow
deny from all
# allow my dynamic IP address
allow from <dynamic ip>

But the problem is that I'll have to manually make this change every time the IP changes.

Ideally I'd like to specify a hostname instead... something like:

order deny,allow
deny from all
# allow my host
allow from hostname.whatever.local

That doesn't seemed to have worked though. I get an error 403 - access forbidden. Does .htaccess not support hostnames?


Solution 1:

That would most likely because Apache doesn't look up the hostname in the direction you are thinking. Instead of looking hostname.whatever.local and allowing that address it does a reverse lookup on the connecting ip address, seeing if the response matches the allowed name.

(Well, actually Apache is doing a double lookup, first a reverse lookup and then a forward lookup on the result of the reverse.)

As the issue is about a dynamic ip address I assume it's PTR isn't simply changed constantly.