Password Protecting Wordpress Subdirectories using .htaccess

Posted on October 31, 2009 
Filed Under Uncategorized | 2 Comments

There are a few different ways to go about password protecting directories in your wordpress blog. You can use a plugin, like The wordpress Password Plugin, or you can do it via your control panel.

I can’t speak for all control panels, but cPanel’s password protect system is pretty straightforward. I chose to use it instead of a plugin because I felt it was a more secure option, and because I generally like to keep the number of plugins to a bare minimum on my site, for a number of reasons, not least because they can be a pain when it comes time to upgrade wordpress.

The process is simple: login to cpanel, go to Security -> Password Protect Directories. Then add the directory you want to protect, as well as usernames and passwords. Easy.

Or at least it should be. Unfortunately, I also use permalinks, and wordpress doesn’t approve of ppl using other directories without its permission. Whenever I punched in the address of my new protected subdirectory, I got a Page Not Found error.

The problem, I discovered, was with the .htaccess files. Here’s the workaround:

Use an ftp editor to open up your site. I use Fireftp, but each to their own. Make sure you enable Show Hidden Files, because .htaccess files tend to be cloaked. Some directories will have a .htaccess file already in them; others won’t.

1. For wordpress subdirectories (ie, http://www.yourwebsite.com/wordpressblog) open up the .htaccess file – located @ http://www.yourwebsite.com/wordpressblog/.htaccess – and add these three lines:

# bypass
ErrorDocument 401 /%{REQUEST_URI}/myerror.html
ErrorDocument 403 /%{REQUEST_URI}/myerror.html

Just before this line:

# BEGIN WordPress

2. For non-wordpress directories your.htaccess file should look like this:

AuthUserFile “/home/username/.htpasswds/public_html/passwordprotecteddirectory/passwd”
AuthType Basic
AuthName “name
require valid-user

ErrorDocument 401 /%{REQUEST_URI}/myerror.html
ErrorDocument 403 /%{REQUEST_URI}/myerror.html

The bold text will depend entirely on the name of your directory, your username etc.

Hope that helps!

~Van

Update

Posted on July 11, 2009 
Filed Under Uncategorized | Leave a Comment

First of all, apologies to those people who occasionally come here (all three of you) to read articles or check out photos. It’s been a long time since I last posted anything remotely interesting. A few reasons for this: I’ve been writing a book (it’s almost done), producing a documentary (not even close to being done) and travelling, first on an extended honeymoon, and secondly to Canada to meet my wife’s relatives. I’m now back home on the Gold Coast surfing finishing off the second half of a course I started last year. I have a bunch of photos from Egypt which I’ll post as soon as I’ve touched them up. In the meantime, for those visiting via my CV, here are a few quick links of some of the more interesting (or less dull, depending on your point of view!) items on my website:

Photography: Don’t forget to check out my pics of North Korea, here; I’ve also succumbed to the pressure and got myself a shiny new flickr account. Many of my pics (save those from my most recent excursions) can be viewed here.

Articles: A few articles I wrote to do with North Korea, the first a travelogue, the second a small number on Korean reunification.

Alternatively, feel free to brave the old posts on the right; or not.

And stay tuned! I’ve got a ton of pics and maybe even a new travelogue or too to check out!

~ Van

PS – here’s an old pic I dug up from my archives. We were filming a TV ad for Ug Boots (Ugz?) in Byron Bay and a couple of Canadian backpackers agreed to help us out. I promised I would send them the pictures when we were done, but I lost their email addresses.

So – if anyone out there recognises this bloke, let me know!

Next Page →