This is the second time I’m writing this post today; remember to save your work before clicking the X argh! O.K. now it’s time to get down to business. I was attempting to password protect a directory to store the old files from a website I just finished converting into WordPress. The problem was that every time I tried to password protect the folder (even though it existed), I would get bounced to the WordPress 404 instead of the folder that was being protected. Having used the .htaccess method to protect files and folders in the past, both with CPanel protected folders and editing the .htaccess manually, I knew it could be done.
I searched all over the web and kept finding people experiencing the same issue but no reason for the problem or solutions were to be found. Finally, after about the 60th search variation I found the cause and solution to the issue posted by Otto in the WordPress forums. In non-technical terms; this happens anytime you try to use .htaccess to protect a sub-folder in the WordPress directory. In my case WordPress was being used as a website, so all folders inside the root are sub-folders of my WordPress installation. The cause seems to be a conflict between the mod rewrite used by WordPress in the root .htaccess file and the way the apache server functions. In essence, apache wants to find it’s own instructions, and WordPress says it’s in charge. Now it’s time to fix the problem –
Create a file on your website called onerror.html. It can have just<html></html> in it for all that it matters. next, in the WordPress .htaccess file, add this to the top of the file:
ErrorDocument 401 /path/to/onerror.html – don’t forget to correct the path and remember it’s relative to your WordPress install)
Then try and add your password protection again.
Well, that’s what solved my problem; hope this prevents others from pulling out their hair because Rogaine is expensive.
Share Your Two Cents