Setup Pretty Permalinks in WordPress

I recently received a Raspberry Pi for my birthday and on my to-do list was to turn it into a web server and host a blog on it.

Using Pretty Permalinks

Setting up the web server proved to be fairly easy and so was the installation of WordPress. However, I wanted to use the Pretty Permalinks feature, so my url's would look clean and readable.


I enabled pretty permalinks in the admin and set the correct permissions on the .htaccess file

$ sudo chmod -v 666 .htaccess

I thought this would be all i needed, however when i clicked on a blog post all i got was a 404 page not found error.




So after having a look on the WordPress support site for Pretty Permalinks I found out that I needed the following:

  • Apache web server with the mod_rewrite module installed
  • In WordPress's home directory,
    • The FollowSymLinks option enabled
    • FileInfo directives allowed (e.g. AllowOverride FileInfo or AllowOverride All)
    • An .htaccess file (if this file is missing, WordPress will try to create it when you activate "pretty" permalinks)
    • If you want WordPress to update the .htaccess file automatically, WordPress will need write access to the file.

Enable mod_rewrite

To enable mod_rewrite, enter this at the command line:

$ sudo a2enmod rewrite

It should tell you to restart apache, so go ahead and do that too:

$ sudo /etc/init.d/apache2 restart

Follow SymLinks and File Info Directives

The next step is to create a virtual host in your apache.conf file, if you haven't done so already. To do this enter the following on the command line:


$ sudo nano /etc/apache2/apache2.conf

and add the following to the bottom of the file:

AddType application/x-httpd-php .html
<VirtualHost *:80>
    ServerAdmin webmaster@yourdomain.co.uk
    DocumentRoot /var/www 
    ServerName yourdomain.co.uk
    ServerAlias www.yourdomain.co.uk
    <Directory />
       Options FollowSymLinks
       AllowOverride all
    </Directory>
</VirtualHost>

Make sure you restart apache again. After doing all of the above, I was able to load pages with the pretty permalinks feature active.


One thing that caught me out was the  "AllowOveride All" I had it /side to "None" initially and I received 404 errors still, so make sure you don't do the same also!

Comments

Popular posts from this blog

Nokia Maps rendering issue using IE8 & Twitter Bootstrap

Setting the path on Google Cookie Choices

Error Using Python Requests Library - TypeError: 'dict' object is not callable