I’m trying to make a website where all users are redirected to a specific part in the domain so that they can see a “comming soon” page. While some ip addresses can still access the normal website so that they can see how it is going to look.
What I’m trying to do: create a wordpress website in the root of public_html, create a soon directory in public_html and redirect all users except a few ip’s to http://www.domain.com/soon/index.html
My .htaccess looks as followed:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^1.2.3.4
RewriteRule (.*) http://www.domain.com/soon/index.html [R=302,L]
However whenever I go to the website to test it out it tells me:
ERR_TOO_MANY_REDIRECTS
Is there something I’m doing wrong in my .htaccess?
Try this:
Use this rule as your very first rule in your .htaccess:
REMOTE_ADDR
matches client’s IP in a web request.RewriteCond %{REQUEST_FILENAME} !-f
is needed to avoid redirecting for css/js/image files and/soon/index.html
file.