I am trying to only show a coming soon or maintenance page to everyone except select IP's. I have tried several solutions now and have settled on this code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^xx\.xx\.xx\.xx
RewriteCond %{REQUEST_URI} !/coming-soon\.html$
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|js|woff) [NC]
RewriteRule .* /coming-soon.html [R=302,L]
</IfModule>
This works great for whenever someone goes to home page. But if you go to any other page, such as /contact, /shop, .etc it doesn't redirect.
I have placed this code at the bottom of the page. When I tried to move it to the top of the page I received an error stating to many redirects. Below is my standard Wordpress redirect.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
How do I restrict all pages to all but select ip's?
Thanks
Edit I have tested on a new server without caching plugins or security plugins that add code to htaccess and I still have the same problem. Requests to homepage get redirected but requests to any other page do not. Below is the code from my htaccess file.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN Trusted Access
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^xx\.xx\.xxx\.x
RewriteCond %{REQUEST_URI} !/coming-soon\.html$
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|js|woff) [NC]
RewriteRule ^(.*)$ /coming-soon.html [R=302,L]
</IfModule>
# END Trusted Access