 <p>This can be achieved by using a script (modify to suit your needs):</p> <pre><code>#!/bin/bash # Dynamic IP .htaccess file generator # Written by Star Dot Hosting # www.stardothosting.com dynDomain="$1" htaccessLoc="$2" dynIP=$(/usr/bin/dig +short $dynDomain) echo "dynip: $dynIP" # verify dynIP resembles an IP if ! echo -n $dynIP | grep -Eq "[0-9.]+"; then exit 1 fi # if dynIP has changed if ! cat $htaccessLoc | /bin/grep -q "$dynIP"; then # grab the old IP oldIP=`cat /usr/local/bin/htold-ip.txt` # output .htaccess file echo "order deny,allow" &gt; $htaccessLoc 2&gt;&amp;1 echo "allow from $dynIP" &gt;&gt; $htaccessLoc 2&gt;&amp;1 echo "allow from x.x.x.x" &gt;&gt; $htaccessLoc 2&gt;&amp;1 echo "deny from all" &gt;&gt; $htaccessLoc 2&gt;&amp;1 # save the new ip to remove next time it changes, overwriting previous old IP echo $dynIP &gt; /usr/local/bin/htold-ip.txt fi </code></pre> <p>Than just cron it to generate a new line on the .htaccess file:</p> <pre><code>*/15 * * * * /bin/sh /usr/local/bin/.sh yourhostname.no-ip.org /var/www/folder/.htaccess &gt; /dev/null 2&gt;&amp;1 </code></pre> <p>Source: <a href="https://www.stardothosting.com" rel="nofollow">https://www.stardothosting.com</a></p>