Skip to content

Instantly share code, notes, and snippets.

@rafaysansari
Last active February 18, 2022 05:54
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 rafaysansari/d50ed4d18bd40f960f8e to your computer and use it in GitHub Desktop.
Save rafaysansari/d50ed4d18bd40f960f8e to your computer and use it in GitHub Desktop.
Restricting access to the WordPress login page using Static IP Address(es). Code caters for redirect loops with the inclusion of error pages.
ErrorDocument 401 /your-site's-path/index.php?error=404
ErrorDocument 403 /your-site's-path/index.php?error=404
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
RewriteCond %{REMOTE_ADDR} !^12\.345\.678\.90
RewriteCond %{REMOTE_ADDR} !^IP Address InsertTwo$
RewriteCond %{REMOTE_ADDR} !^IP Address InsertThree$
RewriteRule ^(.*)$ - [R=403,L]
</IfModule>
Copy link

ghost commented Feb 18, 2022

thank you bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment