Wordpress

Came across this little maddening issue again today after fixing it a few months back. I created a directory that is password protected using a .htaccess file. However, when trying to access this folder or anything under this directory, a File Not Found 404 error from WordPress is displayed before it even prompts you for the password. The problem here lays within the main WordPress .htaccess file

The default .htaccess file for WordPress is:

# BEGIN wordpress

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

# END wordpress

This means that if a file is requested from the server, if it is not a file that exists in the server’s folder directory (!-f) and if it is not a directory that exists in the server’s folder directories (!-d) then pass the request onto index.php. This way, WordPress will handle both customized URLs (such as those used for SEO) and also 404 File Not Found errors.

If you set up a password protected folder in a directory included in a WordPress install, all of a sudden WordPress takes over that folder and returns a 404 page, like the file doesn’t exist.

This happens because of a little ‘gotcha’ in the apache configuration. Luckily it is an easy fix.

In the password protected folder’s .htaccess file, you may already have the entries to ask for password access. Before all of that, place the following line:

ErrorDocument 401 /401.html

Then create a 401.html in the main folder, with any text, for example:

PASSWORD PROTECTED FOLDER - Please enter the correct username/password.

Voila, you can now enter your password protected folder again.

There is another workaround this little error, but since it involves editing the main wordpress .htaccess file, it can be overridden during an upgrade.

Solution found on: http://www.webmasterworld.com/apache/3688208.htm

32 comments
  1. Thanks for the tips. That’s good to know for site I’m working with.

  2. Thanks for the tips. That’s good to know for site I’m working with.

  3. Pingback: Dave Drager
  4. Pingback: Mark Ford
  5. Pingback: richie reveley
  6. Life saver :)

    I spend hours trying to turn off the rewrite engine but no use

    simply this worked .. awesome !

    Regards,

  7. Life saver :)

    I spend hours trying to turn off the rewrite engine but no use

    simply this worked .. awesome !

    Regards,

  8. Business & Administration skills are critical to the growth of the UK economy. As the national standard setting body for Vocational Education in Business, Administration and Governance, the CfA (Council for Administration) leads the UK’s drive for world class skills.

  9. Business & Administration skills are critical to the growth of the UK economy. As the national standard setting body for Vocational Education in Business, Administration and Governance, the CfA (Council for Administration) leads the UK’s drive for world class skills.

  10. David, kudos on this article. It saved me. All of hostgators info was not working…and then I found this. I would think more people would have addressed this…I’m glad you did.

    Cheers,
    Richard

  11. David, kudos on this article. It saved me. All of hostgators info was not working…and then I found this. I would think more people would have addressed this…I’m glad you did.

    Cheers,
    Richard

  12. Pingback: Dave Drager
  13. Great site…keep up the good work. I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say I’m glad I found your blog. Thanks,

    A definite great read…

    – Bill Bartmann

  14. Great site…keep up the good work. I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say I’m glad I found your blog. Thanks,

    A definite great read…

    – Bill Bartmann

  15. Hey, I found your blog while searching on Google your post looks very interesting for me. I will add a backlink and bookmark your site. Keep up the good work!

  16. Hey, I found your blog while searching on Google your post looks very interesting for me. I will add a backlink and bookmark your site. Keep up the good work!

  17. Hey very nice blog!!….I’m an instant fan, I have bookmarked you and I’ll be checking back on a regular….See ya

  18. Hey very nice blog!!….I’m an instant fan, I have bookmarked you and I’ll be checking back on a regular….See ya

  19. Hey, I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say GREAT blog!…..I”ll be checking in on a regularly now….Keep up the good work! :)

    – Marc Shaw

  20. Hey, I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say GREAT blog!…..I”ll be checking in on a regularly now….Keep up the good work! :)

    – Marc Shaw

Comments are closed.

You May Also Like

Anti spam for forums and security

If you have ever run a blog, forum, or any other interactive…

Memory Allocation Problems on Xen Server & Fix

Recently I started seeing this error while provisioning Xen VPSes on a…

Closing a Firefox Window with Javascript

I recently had a problem where I was opening a browser window…