Idgoo
Idgoo

Reputation: 43

Mod_rewrite - deny access except specific pages

Have a rewrite rule that redirects anyone not in the office to a holding page.

RewriteEngine On

RewriteCond %{REMOTE_ADDR} !^x\.x\.x\.x$
RewriteRule . holdingpage.html

RewriteCond %{REMOTE_ADDR} ^x\.x\.x\.x$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [NC,L] 

I need allow google to access its google verification file: https://www.example.com/google23423423463.html

Is there a way to add a rewrite to allow anyone not in the office to access this page, as well as be redirected to the holding page when accessing any other page?

Many thanks,

Upvotes: 1

Views: 116

Answers (1)

anubhava
anubhava

Reputation: 785481

Yes sure you can do:

RewriteEngine On

# If request is for special page, skip all rules below
RewriteRule ^google23423423463\.html$ - [L]

RewriteCond %{REMOTE_ADDR} !^x\.x\.x\.x$
RewriteRule . holdingpage.html [L]

RewriteCond %{REMOTE_ADDR} ^x\.x\.x\.x$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

Upvotes: 1

Related Questions