{"id":2139,"date":"2014-11-11T10:50:44","date_gmt":"2014-11-11T08:50:44","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=2139"},"modified":"2014-11-11T11:09:38","modified_gmt":"2014-11-11T09:09:38","slug":"password-protect-wordpress-logins","status":"publish","type":"post","link":"http:\/\/www.extradrm.com\/?p=2139","title":{"rendered":"Password protect WordPress logins"},"content":{"rendered":"<p>Using the steps below, I&#8217;ll show you how to create password protection for your \/wp-admin directory. We&#8217;ll also copy those rules over to protect your wp-login.php script to keep WordPress as safe as possible.<\/p>\n<p>If you get a redirect loop, make sure you have these ErrorDocument tags in your .htaccess file:<\/p>\n<p><strong>ErrorDocument 401 &#8220;Denied&#8221;<\/strong><br \/>\n<strong> ErrorDocument 403 &#8220;Denied&#8221;<\/strong><\/p>\n<p>Please also make sure to allow \/wp-admin\/admin-ajax.php requests without password protection.<\/p>\n<p>click on password protect directories<\/p>\n<p>Under the Security section, click on Password Protect Directories.<br \/>\nselect document root click goSelect the Document Root for your domain, then click Go.<br \/>\nclick on wp adminClick on your wp-admin directory.<br \/>\ncheck password protect name directory click save<\/p>\n<p>Check Password protect this directory, give it a name, then click Save.<br \/>\nclick go backNow click on Go Back.<br \/>\n<strong>click on password generator and use passwordClick on Password Generator.<\/strong><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/click-on-password-generator-and-use-password.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2150\" alt=\"click-on-password-generator-and-use-password\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/click-on-password-generator-and-use-password-300x212.png\" width=\"300\" height=\"212\" srcset=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/click-on-password-generator-and-use-password-300x212.png 300w, http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/click-on-password-generator-and-use-password.png 642w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nClick on Generate Password a few times, and copy your password.<br \/>\nCheck I have copied this password in a safe place.<br \/>\nThen click Use Password.<br \/>\nclick on add authorized userNow type in a Username, then click on Add\/modify authorized user.<br \/>\nauthentication required click on log inTry to access your \/wp-admin directory.<br \/>\nYour browser will prompt you for the password you just created.<br \/>\nType in your username \/ password, and click Log In<br \/>\nwordpress admin click on log inYour normal WordPress admin login page should now display.<\/p>\n<p>You may encounter a re-direct loop at this point. If so, please ensure you&#8217;ve created the error documents mentioned earlier.<br \/>\nclick on file manager and goNow go back to cPanel.<br \/>\nUnder the Files section, click on File Manager.<br \/>\nSelect the Document Root for your domain.<br \/>\n<strong>Check Show Hidden Files (dotfiles), then click Go.<\/strong><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/click-on-file-manager-and-go.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2148\" alt=\"click-on-file-manager-and-go\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/click-on-file-manager-and-go-300x286.png\" width=\"300\" height=\"286\" srcset=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/click-on-file-manager-and-go-300x286.png 300w, http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/click-on-file-manager-and-go.png 456w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nclick on wp admin and edit htaccess fileFrom the left-hand directory listing, expand public_html.<br \/>\nClick on wp-admin, then right-click on your .htaccess file.<br \/>\nThen click on Edit<br \/>\nFor the encoding pop-up, click on Edit again to bypass that.<br \/>\ncopy htaccess text<\/p>\n<p>Copy all the code in the .htaccess file.<\/p>\n<p>While you still have the \/wp-admin\/.htaccess file open, also go ahead and add the code before AuthType Basic :<\/p>\n<pre>ErrorDocument 401 \"Denied\"\r\nErrorDocument 403 \"Denied\"\r\n\r\n# Allow plugin access to admin-ajax.php around password protection\r\n&lt;Files admin-ajax.php&gt;\r\nOrder allow,deny\r\nAllow from all\r\nSatisfy any\r\n&lt;\/Files&gt;\r\n\r\nAuthType Basic\r\nAuthName \"Secure Area\"\r\nAuthUserFile \"\/home\/example\/.htpasswds\/public_html\/wp-admin\/passwd\"\r\nrequire valid-user<\/pre>\n<p>Now make sure to save the \/wp-admin\/.htaccess file with the added code in it. Because on the next step you&#8217;ll just be editing the \/public_html\/.htaccess file.<br \/>\nclick on public_html and edit htaccess fileFrom the left-hand directory listing, click on public_html.<br \/>\nRight-click on your .htaccess file, then click on Edit.<br \/>\nsave public_html htaccess file<\/p>\n<p>Now paste the .htaccess code you copied, in-between some &lt;FilesMatch&gt; tags, so that it ends up looking like this:<\/p>\n<pre>ErrorDocument 401 \"Denied\"\r\nErrorDocument 403 \"Denied\"\r\n\r\n&lt;FilesMatch \"wp-login.php\"&gt;\r\nAuthType Basic\r\nAuthName \"Secure Area\"\r\nAuthUserFile \"\/home\/example\/.htpasswds\/public_html\/wp-admin\/passwd\"\r\nrequire valid-user\r\n&lt;\/FilesMatch&gt;<\/pre>\n<p>Then click on Save Changes up at the top-right.<\/p>\n<h2>Code review<\/h2>\n<p><strong>You should now have the \/wp-admin\/.htaccess file that password protects the \/wp-admin directory. You then copied that same password protection over to just your main .htaccess file, so that it can also password protect your wp-login.php script directly as well.<\/strong><\/p>\n<p>\/public_html\/wp-admin\/.htaccess<\/p>\n<pre>ErrorDocument 401 \"Denied\"\r\nErrorDocument 403 \"Denied\"\r\n\r\n# Allow plugin access to admin-ajax.php around password protection\r\n&lt;Files admin-ajax.php&gt;\r\nOrder allow,deny\r\nAllow from all\r\nSatisfy any\r\n&lt;\/files&gt;\r\n\r\nAuthType Basic\r\nAuthName \"Secure Area\"\r\nAuthUserFile \"\/home\/example\/.htpasswds\/public_html\/wp-admin\/passwd\"\r\nrequire valid-user<\/pre>\n<p>\/public_html\/.htaccess<\/p>\n<pre>ErrorDocument 401 \"Denied\"\r\nErrorDocument 403 \"Denied\"\r\n\r\n&lt;FilesMatch \"wp-login.php\"&gt;\r\nAuthType Basic\r\nAuthName \"Secure Area\"\r\nAuthUserFile \"\/home\/example\/.htpasswds\/public_html\/wp-admin\/passwd\"\r\nrequire valid-user &lt;\/FilesMatch&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>Step test : Now if someone tries to directly login via wp-login.php they will be prompted for a valid user as well.<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/wp-login-bad-password-attempt.png\"><img loading=\"lazy\" title=\"wp login bad password attempt\" alt=\"wp-login-bad-password-attempt\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/wp-login-bad-password-attempt-300x231.png\" width=\"300\" height=\"231\" \/><\/a><\/p>\n<p>When a user enters invalid credentials are, they will get an Authorization Required error. They will then not be able to attempt to login to your WordPress admin directly.<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/wp-login-bad-password-attempt-blocked.png\"><img loading=\"lazy\" title=\"wp login bad password attempt blocked\" alt=\"wp-login-bad-password-attempt-blocked\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/11\/wp-login-bad-password-attempt-blocked-300x107.png\" width=\"300\" height=\"107\" \/><\/a><\/p>\n<p>You should now know how to requre a username and password before an attempt to directly login to WordPress is even allowed. This will help to protect your WordPress website from unauthroized login attempts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using the steps below, I&#8217;ll show you how to create password protection for your \/wp-admin directory. We&#8217;ll also copy those rules over to protect your wp-login.php script to keep WordPress as safe as possible.&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2842,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31,6],"tags":[],"youtube_video":null,"_links":{"self":[{"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2139"}],"collection":[{"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2139"}],"version-history":[{"count":0,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2139\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2842"}],"wp:attachment":[{"href":"http:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2139"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}