Archive Info

How to Keep WordPress from Overwriting Your .htaccess Edits

Recently I was having problems with WordPress overwriting my .htaccess.  I wanted to do some URL rewriting, but WordPress kept erasing my changes.  I realized that WordPress reserves a portion of the .htaccess file for itself, and it is clearly marked as such.  As long as you don’t put your edits in that spot, they won’t be overwritten.

If only I’d read this article first, I wouldn’t have been scratching my head over this issue :)

Backwards Compatibility Issues

So, when I decided to convert to WordPress from bBlog, I had to decide what to do with all of my old bBlog entries. I came across various home-grown conversion tools that claimed to convert various versions of bBlog installations to various versions of WordPress installations, but I was really leery about using any of them. For one thing, one of the sites I visited generated one of those nice Google warnings about the site being untrustworthy.

I suppose I could have written some code myself to perform the conversion. It probably wouldn’t have been all that difficult. I’m familiar with MySQL databases and have done some hacking both in WordPress and bBlog.

In the end, though, I decided to maintain the look and feel of my old bBlog entries. Why not just keep the bBlog blog and install WordPress on top of it? Installation was no problem…the only file WordPress need to overwrite was index.php. I just renamed bBlog’s to index_bblog.php. Then, with just a little bit of mod_rewrite trickery, I have both blogs available on the same URL!

Here’s my mod_rewrite code, in case somebody wants to do something similar:

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} postid=(.*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !(index_bblog\.php.*)$ [NC]
RewriteRule .* /index_bblog.php?postid=%1 [R=301,L]

RewriteCond %{QUERY_STRING} sectionid=(.*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !(index_bblog\.php.*)$ [NC]
RewriteRule .* /index_bblog.php?sectionid=%1 [R=301,L]

This makes it so anytime bBlog-style entries are requested, because for instance they are still indexed, or linked to from within the entries themselves, the server recognizes them and redirects them to the index_bblog.php file, using the QUERY_STRING info to specify which blog entry is requested. Very handy!