Warning! Geek alert! This post is about messing with the bowels of strange operating systems for arcane purposes. Intermediate knowledge of Wordpress and rudimentary knowledge of the Linux command line are assumed. If you’re here to read about ISP censorship and no-fly lists, you’ll probably want to skip this post.

Wordpress lets you set up pretty permalinks for your posts. However, if you’ve installed Wordpress on a computer running Ubuntu, you need to make some changes to your system’s configuration to get the permalinks to work.

Here’s what I had to do:

1. Enable Apache’s mod_rewrite module:

$ sudo a2enmod rewrite

2. Edit the appropriate config file in /etc/apache2/sites-enabled. Unless you’ve made other changes, the only thing you’ll find in /etc/apache2/sites-enabled is a symbolic link to /etc/apache2/sites-available/000-default — that’s the file you need to edit. You probably installed Wordpress in its own directory in /var/www, so go find the following in 000-default:

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/
</Directory>

…and change both occurrences of AllowOverride to All:

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/
</Directory>

3. Restart Apache:

$ sudo /etc/init.d/apache2 restart

4. There ought to be a .htaccess file in your Wordpress directory with the following contents:

# BEGIN WordPress
<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteBase /wpehlbc/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpehlbc/index.php [L]
</ifmodule>

# END WordPress

If that file (/var/www/wordpress/.htaccess) doesn’t exist, you should create it at this point.

5. In the Wordpress admin panel, go to Options > Permalinks and choose the “Date and name based” permalink structure (or whatever user-friendly permalink structure you want to use). Don’t forget to click the Update Permalink Structure button at the bottom of the page. You should get a notice saying “Permalink structure updated.”

That should do it. If it doesn’t work, or if there’s something wrong with the instructions above (but there shouldn’t be, because this describes my configuration pretty well), please leave me a comment and let me know!