some WordPress pointers …

Ok folks, after wrestling with permalinks and mod_rewrite, I’ve deciphered a number of well-scribbled Post-Its to give you some pointers on how to ‘tune’ your WP blog.

Firstly, your Apache build needs to include mod_rewrite – if it doesn’t, fix this then come back here. mod_rewite is required to enable permalinks and improve the aesthetics of your URI so instead of a messy URI that includes references to hard-coded page entries in MySQL database e.g. …/blog/index.php?p=xxx, you get a nice URI referenced by the title of your post e.g. …/blog/my-post/. Permalinks also create a more constant reference for search engines/RSS feeds, especially if you intend to reindex or change the underlying database of your blog later.

Problem 1: Permalinks do not appear to work.

1. Check your Apache httpd.conf (in /etc/httpd/) and make sure that within the ‘Directory’ tag, Allow Override is set to ‘All’
2. Check for existence of a .htaccess file in your blog directory, if not create one by touch .htaccess
3. Make sure .htaccess has correct permissions, chmod 666 .htaccess should do the trick
4. Go back to WP admin, and under Options/Permalinks, select a template tag for your structure – if you’ve done all the above, WP should edit the .htaccess automatically.

Problem 2: Trailing slash is missing in the header URI.

This is a really irritating problem. In WP 1.5 (upwards), the trailing slash has been removed (ostensibly for consistency!) such that when you click on the header hyperlink to take you back to your blog’s index.php page, you get a 404 error instead. There are a couple of ways to fix this:

1. add the trailing slash yourself in themes/header.php wp-register.php and wp-login.php (not very elegant since this requires constant changes if you use multiple themes)
2. add a ReWriteRule in your .htaccess file as follows:

ReWriteEnginge On
ReWriteBase /your-blog-directory-name/
ReWriteCond %{REQUEST_FILENAME} -f [OR]
ReWriteRule you-blog-directory-name /your-blog-directory-name/index.php [L] *** add this line

What this does is everytime Apache gets a URI request pointing to the directory of your blog with a missing trailing slash (if there’s no /, Apache thinks you’ve requested a file rather than a directory), the rewrite rule appends /index.php to the URI, thus avoiding the 404 error. The [L] then tells the rewrite to stop after executing this rule.

Tomorrow, I shall tackle themes to improve the ‘look’ of my WP blog but for the moment, this blog has been imported into WP from blogger.com

Leave a Reply

Your email address will not be published. Required fields are marked *