I want restrict all users to access WordPress website login.
For example: Suppose I have WordPress website domain example1.com
and I want to restrict all users to access admin login with example1.com/wp-admin
and example1.com/wp-login.php
.
When any user hits these url it redirect to restrict_user page and also I want to access wordpress login page with example1.com/user_login
instead of hit example1.com/wp-admin
and example1.com/wp-login.php
urls.
And please suggest me how can i make my WordPress website more secure from hacking?
You can lock down the wp-admin page with htaccess deny all and hen setting an allowed ip.
You can also set a htpasswd file with allowed logins and password protect the page. I would also make sure your username in wp-admin is not something easy like ‘admin’ or ‘editor’.
Furthermore i would highly recommend wordfence as a good plugin for protection from hacks etc.
Restricting access to
wp-admin
directoryApache 2.4+
Add this snippet to your
.htaccess
file, created inwp-admin
directory:and add as many IP Address/Subnet Mask pairs, as you wish, regarding the client IP address you would like to have access to admin area. I have added two samples above.
Apache 2.4-
Add this snippet to your
.htaccess
file, created inwp-admin
directory:Restricting access to
wp-login.php
pathAdd this snippet to you current theme’s
functions.php
file:Changing the
wp-admin
pathIt is possible to change it, but why do you think that has any value at all? You cannot hide anything from a Bot – that is just not possible to do.
Hackers use automated Bot programs to find whatever they want to find.
A good approach is Action Approach:
So just use the presented method in Restricting access to wp-login.php path section and that will be OK.
From nginx, using php7.0-fpm on Ubuntu 16.04LTS.
My base configuration I modified from:
https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04
I found a bunch of configs online that tried to combine
wp-login.php
andwp-admin
into the same rule, but allowedwp-login.php
to be raw downloadable!Granted, its a generic WordPress file, but that is dangerous behaviour.
I’ve separated the rules, since
wp-admin
is a folder, anything accessed within will follow generic rules for images/php/etc. Forwp-login.php
I wanted to specifically replicate php execution. I’ve allows full internal network access to10.x.x.x
.