Fixing .htaccess in WordPress

Well. My good friend Bryan Ens pointed out that my RSS feed was wrecked yesterday. On further study, i realised all my links were toast. This is bad. The home page worked, but no other page did. *sigh* So I set out to figure out what went wrong and repair it.

Turned out my .htaccess file was messed up. This is the file that does all the fancy URL rewriting so my site links aren’t all “jasonfriesen.ca/news/?id=2952”-style.

A-ha! My .htaccess looked a little something like this:


# BEGIN WordPress

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

But you, dear reader, will know that you’re currently reading jasonfriesen.ca/news/. Like many “bloggers”, I post to a subdirectory of my site. Suddenly this information was gone.

Well, I thought: RewriteBase is set to look to /, or the root of the site. Let’s modify that to /news/. That should work. Not so, because when I did so, I found all links went to jasonfriesen.ca/news/ — not to the RSS feed or archive pages.

Hrmm…

The answer, of course, was embarassingly simple. Perishable Press had the answer:

If WordPress installed in a subdirectory called “foo” »

# BEGIN WordPress

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

# END WordPress

I had neglected to set the RewriteRule to redirect traffic to /news/index.php. So it was sending traffic to jasonfriesen.ca/index.php, which is set to send all traffic to jasonfriesen.ca/news/index.php. *facepalm*

When I completed the RewriteRule properly, it all began to work again.

I suspect it happened when I was fixing the .htaccess in a number of other domains in this hosting package; I think I accidentally replaced this one with a modified one. Ah well, clearly I need a vacation; my brain is obviously not too sharp right now.

Sort-of Helpful Links

One thought on “Fixing .htaccess in WordPress”

  1. Nice website! I’m using the same theme and I’ve been having a .htacess problem. I found your site through Google. I’ll add you to my RSS reader! Peace.

Comments are closed.