Resolving 403 forbidden page error for WordPress blogs

Few years back, I decided to move and completely re-purpose my blog from Blogger/Blogspot to WordPress. The transition was mainly driven by a desire to host the blog on my own domain since that gives me a lot more flexibility to customize and manage the content. Luckily, my hosting provider had a ready installation package for setting up a wordpress blog and so that part went relatively smoothly. However, once I tried to launch the landing page of the blog, I got page forbidden (403) error. Incidentally, it was occurring on every relative URL/page for the blog (including /wp-admin). After quite a bit of hassle, I was eventually able to resolve the issue and things seemed to work alright from that point onward. I thought of documenting an abbreviated version of the procedure in case anyone else might run into a similar problem while transitioning their blog to WordPress.

Firstly, I checked the permissions on the installation folder (in my case, <root>/blog) and found it to be OK (755 for read / execute to world).

Next, I checked .htaccess located under /root folder. I had a prior Ruby on Rails install that had the following configuration –

RewriteEngine on

RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^contest{REQUEST_URI} [P,QSA,L]
DirectoryIndex preload.html index.html
# BEGIN WordPress

# END WordPress

I had a hunch that the URL rewriting module might’ve been misbehaving, but didn’t want to tinker with it since I may have needed the RoR app (dormant at the time) to come alive sometime in the future. What I did instead was to change the .htaccess file in the /blog folder from –

DirectoryIndex index.php
AuthUserFile “/home/sushainp/.htpasswds/public_html/blog/passwd”

to –

DirectoryIndex index.php
AuthUserFile “/home/sushainp/.htpasswds/public_html/blog/passwd”
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

# END WordPress

This effectively ended up overriding the URL rewriting defaults for everything matching /blog/* URL pattern and thus, resolved the issue. For those of you interested in learning more about URL rewriting module, more information is available here.