On a website I manage, I want to use an .htaccess file to allow access to a certain administrative directory only from my home IP address, which is dynamically assigned by my ISP and therefore changes -- not regularly, but it does happen.

I also have an account from DynDNS and have one of the auto-update clients making sure it always points to my actual home IP address. I don't actually host anything at home; I just have set up the Dynamic DNS account.

Is there any way to combine these features: that is, is it possible write the .htaccess allow/deny commands at my outside webhost in a way that my home IP address is not hard coded into the command, but instead is somehow derived from the Domain Name that the DynDNS has assigned me, by doing a real-time lookup every time the directory's .htaccess file is hit?

1 Answer 1


That's pretty complicated and not a common way to restrict access. You would need a script on your web server making a call to DynDNS using their API http://dyn.com/support/developers/api/ checking for a new IP. Then given you can get a response from their API using your account and have your new IP insert it into the .htaccess file. I'm not sure if you would have to refresh the visitors connection to account for changes to the htaccess file but it seems like it's more work and complicated than worth doing.

It may be easier to password protect your private area than restricting access by IP. What if you're away from home and needed to access that area? Even if you setup your ISP's domain as allowed you still may not be able to access it in some cases.

This is a really easy to use PHP Login script http://codecanyon.net/item/php-login-user-management/49008

You can also find a few free open source scripts on Google

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.