Skip to content

WordPress Permalinks

If like me you’ve run into the wonders of WordPress permalinks previously and hit brick walls such as 404 and 403 HTTP errors when you change from the default ?p=ID to the pretty /blog/2007/07/12/entry, then this post is for you and the many other people who have asked me this question previously. πŸ™‚ Not sure why considering the fact that I use MovableType as my blogging software but anyway!

Changing your permalink structure from the WordPress default to the pretty, year/month/day/entry-id or similar custom structure can cause problems for some people depending on the setup of their hosting infrastructure. [..]

In order to provide these pretty little URLs WordPress needs to make use of a clever little URL rewrite recipe for Apache. Usually this is provided for you by WordPress: It will either be entered into a .htaccess file automatically if permissions allow or it will be displayed at the bottom of the permalink update page. The code looks like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~jbwan/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~jbwan/wordpress/index.php [L]

Ideally the permissions should allow WordPress to update this file automatically but it’s not a disaster if they don’t. Either change the permissions on the .htaccess file in the root directory of your blog to fully writable by all (remember to make it safe again later by returning the original permissions) and run the WordPress permalink update page again or simply edit the file on the server if you have a shell account and add the lines above. This typically solves the problem for most folk and away they go.

While the previous step will remove the usual 404 errors it sometimes happens that this is not enough to solve the problem. There are two other potential problems that still remain and both will throw up either a 404 or a 403. If you are still getting a 404 trying to access the pretty permalink URLs then the problem is most likely the setup of your hosting provider. Chances are that they have not allowed overrides for the Apache setup relating to your domain, thus denying anything that you have written in the .htaccess file. If you have control of your server then simply edit the httpd.conf file relating to your site root or alternatively the user.conf file for an individual so that something like the following is present:

<Directory "/Users/jbwan/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all

The important line here is the AllowOverride All which is most likely set to None if you are experiencing this problem. After editing either of these files you will need to have the Apache web server restarted. If however these lines are already in place and the error that you are experiencing is a 403 Permission Denied error then the problem can be solved through your own account without help from the hosting provider. The solution to this problem is to edit the .htaccess file in the root directory of your blog and add the following line to the top of the file before anything else:

Options +FollowSymLinks

This should solve the traversal problems that Apache is reporting through the 403 with navigating to the virtual directory and giving permissions to the web user to view the content. After that you should be flying and if not then you’ll need to contact your host to report a more serious problem. Happy permalinking! πŸ™‚

5 thoughts on “WordPress Permalinks”

  1. Happy to see that this quick help post is still helping people – still cannot believe that it’s not mentioned in WordPress’ documentation though as an FAQ given the number of hits I get for this and the number of other sites out there with parts of the solution.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.