Reputation: 23
I am a novice, please help me, all i want is to redirect all other users to 403.php
page except for few specified IP address.
I am working on a wordpress site so www.example.com/wp-admin
is the page (directory) which i want to redirect
Upvotes: 2
Views: 436
Reputation: 19016
You can put this code in your htaccess
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^xx\.xxx\.xxx\.xx$ # IP1 allowed
RewriteCond %{REMOTE_ADDR} !^xx\.xxx\.xxx\.xx$ # IP2 allowed
RewriteCond %{REMOTE_ADDR} !^xx\.xxx\.xxx\.xx$ # IP3 allowed
RewriteRule ^wp-admin(/.*)?$ /403.php [R,L]
Don't forget to replace x
characters (you can add same line for each except IP you want).
Also, you want to redirect to 403.php
which means you want to forbid access (403).
You could use F
flag (forbidden) instead
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^xx\.xxx\.xxx\.xx$
RewriteCond %{REMOTE_ADDR} !^xx\.xxx\.xxx\.xx$
RewriteCond %{REMOTE_ADDR} !^xx\.xxx\.xxx\.xx$
RewriteRule ^wp-admin(/.*)$ - [F]
Upvotes: 1