Skip to content

Instantly share code, notes, and snippets.

@grayghostvisuals
Last active December 17, 2015 00:10
Show Gist options
  • Select an option

  • Save grayghostvisuals/5518833 to your computer and use it in GitHub Desktop.

Select an option

Save grayghostvisuals/5518833 to your computer and use it in GitHub Desktop.
Protects WordPress login page via .htaccess trickery. Only allows access via specific IP addresses designated. The cons are that you cannot access the WordPress login when traveling unless you know specifically the IP for your location. You will then have to add that new IP to the .htaccess rules below. I use the terminal to sniff the IP address…
# Place this .htaccess file within your WordPress wp-admin directory
# This is the IP address of your local network.
# IP Whitelist XX.XXX.XXX.XXX
# Protect your wp-admin .htaccess file to a specific IP.
# Feel free to have multiple IP's.
# Simply copy and paste additional
# 'allow' rules beneath your first.
<Files "*.*">
Order Deny,Allow
Deny from all
Allow from XX.XXX.XX.XXX
</Files>
# Secure 'wp-admin' directory and redirect if the IP does not match.
# replaces the x's with your specific IP address.
# You can have multiple address just copy that line and paste the
# copy below.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^XX\.XXX\.XXX\.XXX
# Give out the redirected address to the criminal. Customize the URI if desired.
RewriteRule ^(.*)$ http://goodluckwiththatdude.com [R,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment