Last active
February 27, 2020 21:38
-
-
Save JayHoltslander/45d421addcb4d09ca077e2e24b1aa835 to your computer and use it in GitHub Desktop.
Redirect unauthorized IP addresses that try to access Wordpress' wp-admin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# REDIRECT UNAUTHORIZED IP ADDRESSES THAT TRY TO ACCESS WP-ADMIN | |
# | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteBase / | |
# ======= IF YOU WANT INTO THE WORDPRESS ADMIN AREA... ======= | |
RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR] | |
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$ [OR] | |
RewriteCond %{REQUEST_URI} ^/wp-admin.* | |
# ======= AND YOU'RE NOT AT ONE OF THESE IP ADDRESSES... ======= | |
# | |
# ===== OFFICE ===== | |
RewriteCond %{REMOTE_ADDR} !^321.654.123.456 [NC] | |
# ===== HOME ===== | |
RewriteCond %{REMOTE_ADDR} !^123.654.456.321 [NC] | |
# ===== SOMEONE ELSE ===== | |
#RewriteCond %{REMOTE_ADDR} !^XX\.XX\.XX\.XXX [NC] | |
# ======= THEN YOU'RE FORBIDDEN AND ARE SERVED AN ERROR PAGE TELLING YOU SO ======= | |
RewriteRule ^.*$ - [L,F] | |
ErrorDocument 403 https://youtu.be/cQ_b4_lw0Gg | |
</IfModule> | |
# ==================================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment