Setting up permalinks on WordPress

This site runs on a Ubuntu 12.04 LAMP server behind another Ubuntu Apache proxy using a virtual host. When I tried to set up the permalinks it didn't work straight away. The .htaccess file was correct and mod_rewrite was enabled. It was the virtual host that had some issue.
The website has been configured under /var/www/ and these are the steps you should take to make sure the permalinks work:

  • Open .htacces in /var/www/ and change it to look like this:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
  • Enable mod_rewrite for Apache:
    sudo ae2enmod rewrite
  • Create your host configuration in /etc/apache2/sites-available/ and make it look like this:

    <VirtualHost *:80>
        DocumentRoot /var/www/
            Options FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Options Indexes FollowSymLinks -MultiViews
            AllowOverride all
            Order allow,deny
            allow from all
        ErrorLog ${APACHE_LOG_DIR}/
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/ combined

That should do the job.

Leave a comment

Your email address will not be published.