.htaccess redirect to all IP's but mine

You could do it with mod_rewrite

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=123.45.67.89
RewriteRule index.php$ /construction.php [R=301,L]

You'll need some conditions before redirecting:

RewriteCond %{REMOTE_ADDR} !=1.3.3.7
RewriteCond %{REQUEST_URI} !=/construction.php
RewriteRule .* /construction.php [L]

Also, to make sure after the lock-out is removed, clients will see the actual page, this solution does not redirect clients permanently (using a 301 redirect), but internally redirects. Substitute 1.3.3.7 for the actual IP address you're using.


If your apache version is 2.4* , You can redirect your visiters to construction page using the following directives in htaccess :

<If "%{REMOTE_ADDR} !='yourIp'">
RedirectMatch ^/((?!construction.php).*)$ /construction.php
</If>

It says if the ip address is not yourIp redirect all requests to /construction.php .

On older versions of apache, you can use the following mod-rewrite based solution :

RewriteEngine on

RewriteCond %{REMOTE_ADDR} !^myIP$
RewriteRule !construction\.php /construction.php [L]

This internally forwords the request to /construction.php if the RewriteCondition meets. You can Replace L with R if you want to see the redirected url in browser address bar.