Skip to content

Instantly share code, notes, and snippets.

@JayHoltslander
Last active February 27, 2020 21:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayHoltslander/45d421addcb4d09ca077e2e24b1aa835 to your computer and use it in GitHub Desktop.
Save JayHoltslander/45d421addcb4d09ca077e2e24b1aa835 to your computer and use it in GitHub Desktop.
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