I'm attempting to use a .htaccess file to block access to the wp-admin folder. I've read through the Brute Force Attacks doc (https://wordpress.org/support/article/brute-force-attacks/) and I've added the block below, using my ip addresses, to the .htaccess file and placed it in the wp-admin folder:
# Block access to wp-admin.
ErrorDocument 401 default
order deny,allow
allow from x.x.x.x
allow from y.y.y.y
allow from z.z.z.z
deny from all
It seems to be working but the error that a user receives is "This webpage has a redirect loop". Is there a way to send the user to a 404 or another error doc instead of the redirect loop? I'm not really sure how that is occurring since there is nothing else in the .htaccess file.
I'm not password protecting the wp-admin folder and adding ErrorDocument 401 default doesn't seem to work either.
ErrorDocument 401 default
line to the end of your.htaccess
file? I know I've run into situations with my own.htaccess
file where the order of the commands is important. (Also, I note that in your answer, thedeny from all
line occurs before theallow from [x]
lines, which may also be relevant.)