Howto enable Permalinks in WordPress on LAMP

In my last post about setting up WordPress on a LAMP, I omitted how to successfully enable permalinks, something you of course want to have on your blog.

Permalinks in WordPress is a way to have pretty URL:s to your posts to make it easy to link directly to them, and give them a human-readable format.

For it to work in a LAMP environment, you need to have mod_rewrite enabled in apache, and the tricky part when it comes to WordPress, is to enable mod_rewrite on the directory where your blog resides.

Most linux distros default to rather sane settings, and typically have something like this in them:

    <Directory "/var/www/html">
        Options FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

that means (if /var/www/html is your DocumentRoot), that WordPress’ way of using .htaccess to control the rewriting with mod_rewrite, will not work as intended (due to the AllowOverride None directive).

The fix is easy. Just add something like this to your apache config:

<Directory "/var/www/html/wordpress">
    AllowOverride All
</Directory>

And you’ll be all set! (replace /var/www/html/wordpress above with the directory where you have wordpress installed. The same directory where wordpress created the .htaccess file when you enabled permalinks)

Leave a Reply