How To: Use Nice Permalinks

Posted by kenchill. Categories How-to, Technology, WordPress

If you are using the WordPress engine to power your blog and haven’t really configured it yet, chances are that you are using the standard permalink structure for your posts.

The standard permalink structure is where the ‘p’ represents the post ID. This is the standard, straightforward URL parameter used on the web. I am sure most of you have seen other blogs which have permalinks which looks like Compared to the default permalink structure, the latter structure is much more descriptive in which it already gives you a rough idea of the post before even clicking on it. It should be something related his/her Bali trip. Besides that, it even has the year and month on it, so you may or may not click on it depending on how up to date the post is.

Descriptive and detailed is what everyone wants on their blog in order to rank higher on search engines. In other terms, optimizing your URL is, in fact a part of the Search Engine Optimization (SEO) process (just one part though, there’s a whole lot of things to do if you want to do proper SEO for you blog/website).

To change the permalink structure of your WordPress blog, you need administrative privileges to the administration section of your blog. The username you are using to publish posts might or might not have administrative privileges. You then need to head to the Settings section (its located on the top right side of the page) and click on the Permalinks tab. You can then select a predefined permalink structure from there or defined your own custom one. For a list of supported tags, visit the WordPress codex:

Now comes the second part of the process. If you give write permissions to WordPress to your .htaccess file, then you can let WordPress handle this part. The easiest way is to create a .htaccess file using the online file manager through your web hosting control panel and temporarily assign its permission settings to 777, and then change the permalinks structure. If not, you need to do it yourself.

Depending on your hosting account, if you have the appropriate rights and privileges, it will be very easy. By changing your permalinks to the ‘/date/title’ or custom structure, you will make the Apache web server confused. For example, if your permalink is then Apache will try to look for a directory called 2008, the subdirectory 05, and then 09, and lastly my-new-post. What you get is NOT the blog post, but a 404 error page.

WordPress won’t create the directory structure for you, and, NO, you do not have to create the directory structure yourself. What you have to do is do enable a module called mod-rewrite in Apache. Don’t worry, you don’t have to configure the httpd.conf file (which is good because you won’t be able to touch that file if you are on a shared hosting package). What you have to do is to create a file called .htaccess (yes, with the period at the beginning, which is used to signify a hidden file in the Unix file system) in your website’s root directory and putting some configuration settings in it to enable mod rewrite and make it work correctly to accommodate the new permalink structure.

Configuration settings:

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

There are a couple of ways in doing this.

FTP Upload

This is by far the easiest and quickest way but you will need an FTP account setup for you with write permissions to the root directory of your website. You will have to create a text file on your computer first, which will of course be named .htaccess (if you are using Windows, then name the file htaccess first, as Windows won’t allow you to begin your filenames with a period). Now, open the file with a text editor and copy the configuration settings into the file and save it.

The next step is to simply connect to your web server via FTP and upload the file to your website’s root directory. If you named the file htaccess on your PC, then you need to rename the uploaded file to .htaccess after the upload is finished.

Online File Manager

This can be done through an online file manager on your server (most likely through the CPanel administration service). You need to browse to your website’s root directory and create a file called htaccess. There is a high possibility that if you name the file .htaccess, it will be hidden from the file manager, thus making it impossible to edit the file to include the configuration settings in it. So, name it htaccess first.

Once the file is created, edit the file and copy the configuration settings into it. After saving the changes, you can then rename the file to .htaccess.

Shell/terminal Access

If you plan to use this technique, I guess I don’t have the need to explain the steps in detailed. Just create the .htaccess file in the website’s root directory and use VI to copy the configuration settings into it, then :wq, and it’s all done!

Double Check

Now it’s time to check whether the new permalink structure and mod rewrite is working or not. You can just head to your blog main page and take note of the links of your blog posts. If they are nicely structured according to your settings and clicking on them takes you to the post page, then everything is working fine! If not, drop me a line/comment!

For more info, do check out the WordPress codex:


Leave a Reply

XFM. Kami Tak Hot, Kami Cool!