While working on this site, I was faced with an interesting problem. There are certain management-related parts of this site which I want to only be accessible from my computer. Usually, a web developer would use an apache .htaccess file to achieve this, by allowing traffic only from a certain IP. The problem is that I have a dynamically assigned IP address from my ISP. It doesn't change often, but it does change sometimes. It would be a pain to have to update the .htaccess file any time my IP address changed. Then I remembered that my router is configured to update to a dynamicDNS address. Using PHP's gethostbyname function, I did a reverse look-up on my dyndns address, and checked to see if it matched the IP address of the visitor. If it did, I would allow access, otherwise I would deny it. For other people with dynamic IP addresses, you might want to try this out if you ever need to control access to your site.
Dec. 20, 2009, 10:01 a.m.