Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from superuser.com May 31 '12 at 19:20

This question came from our site for computer enthusiasts and power users.

up vote 1 down vote accepted

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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