.htaccess script Restrict by IP (CloudFlare compatible version)

Here is a .htaccess script to restrict access to your website.

It will allow the two specified IP addresses to connect and view the site as usual, and all other visitors will be redirected to the “example.com” URL
Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_URI} !http://domain.com$
RewriteCond %{HTTP:X-FORWARDED-FOR} !^12\.3\.45\.678
RewriteCond %{HTTP:X-FORWARDED-FOR} !^876\.54\.32\.111
RewriteRule $ http://example.com [R=302,L]
Allow from
Allow from 876.54.32.111

Use it to hide your “under construction” or “under maintenance” sites and pages from public view by placing it in a web accessible directory, and saving with the name: .htaccess