Clean URL’s with WordPress

This tutorial will show you how to setup WordPress to use clean URL’s. Using clean URL’s is one of the first step in Search Engine Optimization (SEO). Besides that, they just look better.

The default WordPress URL structure is: http://www.yoursite.com/?p=123. What does p=123 even mean? Well, I would guess that it is the post id, but what does your reader see? A URL like this will be much better: http://www.yoursite.com/category/title-of-the-post be much better. It will have some meaning to your readers, and more importantly, search engines. The title is one of the most important things a search engine will look at. The better your site places on the SERPs (search engine results page), the more traffic you will drive to your site. Of course this is only one step in SEO, but is a good start.

There is one thing to keep in mind before you change your permalink structure. You will lose inbound links from other sites and search engines. If you have a large amount of traffic from direct addresses or bookmarks, you will not have to worry about this. If you are just starting out (as we are here at www.tutorials.bot), I would recommend going with clean URL’s from the start. It is really simple to make a custom permalink structure for WordPress.

First, if your .htaccess file is writeable, WordPress is supposed to update it automatically. If not it will give you the code to cut and paste into your .htaccess file. I have had problems letting WordPress edit the .htaccess file in the past (it never seems to update it), so I will edit it manually.

Log on to your WordPress account as the administrator and click on Options and then Permalinks. You should see a page similar to the one below.
Clean URL’s with WordPress

As you can see, the default settings are select. We want to enable custom URL’s so click the option button next to “Custom, specify below”.
Clean URL’s with WordPress

Now we need to define the URL’s. There are many variable that you can use, but I will choose to use the category and postname variables. If you would like to use something else (day, month, year, posted, subcategory, etc.) you may want to see the custom permalinks page on the Official WordPress site. In the “Custom Structure” box, enter the following.
Clean URL’s with WordPress

Now scroll to the bottom and click the “Update Permalink Structure” button.
Clean URL’s with WordPress

Now, if you have a writeable .htaccess file, you can ftp to your site and check to see if .htaccess file was edited. If your .htaccess is not writeable, or WordPress didn’t update it, you will need to enter the following code in the file and upload it to your site.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>

This will tell the server that when it see http://www.yoursite.com/categiory/post-title-here to rewrite it to http://www.yoursite.com/index.php?somevariable , but the user will see the clean URL.

To test it, make a new post or use an existing one. Click the link from your homepage to get to the permalink and look at the URL in the web browser. You should see the clean URL and the page should be displayed properly.
Clean URL’s with WordPress

Here is our ugly default URL versus the clean URL for the same post.
Clean URL’s with WordPress

Vs
Clean URL’s with WordPress

This is an easy way to optimize your site for search engines and be easier on your readers eyes. If you have any questions, just leave a comment, I will answer as quickly as possible.