Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Redirect unauthorized IP addresses that try to access Wordpress' wp-admin
# 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
You can’t perform that action at this time.