Password Protected Folder Gives 404 Not Found in WordPress Installation Sub-folder.



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:

1
2
3
4
5
6
7
8
9
# BEGIN wordpress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# 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:

1
ErrorDocument 401 /401.html

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

1
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

  • John Lauber

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

  • John Lauber

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

  • Pingback: Dave Drager()

  • Pingback: Mark Ford()

  • Pingback: richie reveley()

  • AddaxSoft

    Life saver :)

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

    simply this worked .. awesome !

    Regards,

  • AddaxSoft

    Life saver :)

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

    simply this worked .. awesome !

    Regards,

  • hoboX10

    I freaking love you. Thanks!!

  • hoboX10

    I freaking love you. Thanks!!

  • administration job

    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.

  • administration job

    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.

  • Bill Bartmann

    I’m so glad I found this site…Keep up the good work

  • Bill Bartmann

    I’m so glad I found this site…Keep up the good work

  • Richard Cummings

    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

  • Richard Cummings

    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

  • Pingback: Dave Drager()

  • Bill Bartmann-

    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

  • Bill Bartmann-

    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

  • Tony Brown

    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!

  • Tony Brown

    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!

  • Carl Vandors

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

  • Carl Vandors

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

  • Marc Shaw

    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

  • Marc Shaw

    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

  • Ryan

    awesome!!!!!!!
    what a life saver

  • Ryan

    awesome!!!!!!!
    what a life saver

  • Awesome – I was trying to figure this out and you’ve saved me a lot of time!

  • Awesome – I was trying to figure this out and you’ve saved me a lot of time!

  • really helpful. Thank you very much

  • You’re welcome!

  • Ir

    THANK YOU!

    This has been driving me insane for ages.

  • No problem!