How To Resolve 404 Error When Password Protecting WP-Admin Directory

Well if you’ve come to this blog post you’ve probably tried to password protect your wp-admin directory in WordPress and received a 404 error.

The likely reason you are having this issue is because of the rewrite engine WordPress uses to make search friendly URL’s puts a .htaccess file in the root folder of the WordPress installation, and the code in the .htaccess file causes WordPress to take any unknown URL and serve the appropriate page or error. Your file should have code similar to this:


# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

In my case the password protected page wants to tell me about the 401 situation I am in (authentication) but my server has a default location for this, and there is no file there. So WordPress passes us a 404 error.

The solution is to download .htaccess file where WordPress is installed via FTP, open it using notepad or similar and add the following code before the WordPress entries, or modify the current ErrorDocument 401 line to the following:

ErrorDocument 401 default

Save the file, then re-upload it via FTP. Now, when you try accessing the protected folder you should get a pop-up box asking you to enter your user name and password.

Note: After I fixed my wp-admin password protection issue, I was no longer able to use the flash file uploader within WordPress. I now have to use it in browser uploader mode, by doing so it works just fine.


Be the First One to Know when there are more great posts like this one!


2 Responses to “How To Resolve 404 Error When Password Protecting WP-Admin Directory”

  1. David Says:

    Wesley,

    I can’t thank you enough! This has been bugging me for a while now and this post has saved me from going mad :) one of my websites was hacked the other day (someone managed to upload a fraudulent website in one of the folders, sorted now though) but thanks to this post I can protect folders at will without getting errors.

    Thanks again,

    David

  2. Wesley LeFebvre Says:

    Sorry to hear that you were hacked, David. But, I’m glad to know I was able to help you protect your folders in the future.

Leave a Reply