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/blog.your-site.name and these are the steps you should take to make sure the permalinks work:

  • Open .htacces in /var/www/blog.your-site.name 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]
    </IfModule>
    
  • Enable mod_rewrite for Apache:
    sudo ae2enmod rewrite
  • Create your host configuration in /etc/apache2/sites-available/blog.your-site.name and make it look like this:

    <VirtualHost *:80>
        ServerName blog.your-site.name
        ServerAdmin admin@your-site.name
    
        DocumentRoot /var/www/blog.your-site.name
        
            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}/blog.your-site.name-error.log
    
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
    
        CustomLog ${APACHE_LOG_DIR}/blog.your-site.name-access.log combined
    
    </VirtualHost>
    

That should do the job.

Leave a Reply