Skip to content

Instantly share code, notes, and snippets.

@devuri
Created June 25, 2021 20:09
Show Gist options
  • Save devuri/650f7495c5268ad1c3ae8d0f1c0f05d9 to your computer and use it in GitHub Desktop.
Save devuri/650f7495c5268ad1c3ae8d0f1c0f05d9 to your computer and use it in GitHub Desktop.
Hiding the WordPress Login Page, Hide WordPress Login by restricting access to IP Address With .htaccess
# BEGIN WordPress
# https://wordpress.org/support/article/htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Protect admin page and login page.
# Only accessible by defined IP.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123$
RewriteRule ^(.*)$ - [R=403,L]
</IfModule>
# custom error messages
ErrorDocument 403 "You don't have permission to access this URL."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment