In the past few months I have setup and helped others install and configure WordPress blogs many times. One of the more frequent questions I get pertains to this page in the WordPress admin labeled permalinks. The easiest way to describe permalinks is by saying that they are pretty URLs. For example, enabling permalinks on your WordPress blog changes http://www.yourdomain.com/index.php?p=102 to something like the following URL: http://www.yourdomain.com/2006/04/30/apple-releases-ipod-micro (although permalinks can be setup to display in various formats).
Technically Speaking
Permalinks work by adding an entry into a .htaccess file, which lies at the root public html directory of your server (this might be a folder named httpdocs, www, public_html, etc. – it should be obvious). This is a powerful config file or “distributed configuration file” that can carry out actions in the Apache webserver on a per-directory basis. Permalinks usually rely on mod_rewrite, part of Apache, to turn the post ID URL into the nicer URLs you see on this site. Below is what the typical .htaccess file for a permalink-enabled WordPress blog looks like.
# BEGIN WordPress
<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</ifmodule>
# END WordPress
I don’t want to delve into the world of .htaccess hacking but I will mention that if you add to it, such as making a custom error page, make sure to have that outside of the # WordPress tags completely. Anything in between those two will get overwritten anytime you add a page to your blog or make changes in the WP admin affecting permalinks (hat tip to Kristin for the reminder).
Set Them Up
Before I go about professing the sheer joys of using permalinks, let’s make sure your blog can strut permalinks. Login to your server and navigate to the aforementioned public web directory. Make a new, blank plain text file (none of that .rtf or .doc stuff) in that directory and label it .htaccess; the dot is very important. You might need to have your FTP client set to show invisible files or not hide them – a quick peek in the options should solve this. Now right-click on this file and select get info or some option with chmod, this varies by FTP client so I can’t cover all the bases. We are going to want to perform a chmod 777 so that we can change options in WordPress and let it have the ability to write to the file. Once you have done that, login to your WordPress admin and go to Options » Permalinks. You will be confronted with a few options as to how you want to format your permalinks. The most widely used format is date and name based, however you can pick whichever you like. When you’ve selected the format, just click on Update Permalink Structure. Now go back to your FTP client and perform a chmod 644 to ensure that nothing bad can happen to your omnipotent .htaccess file from outside sources. You’re done!
If you receive any Error 500: Internal Server Error, this is most likely from a botched .htaccess configuration. Go back and ensure that your file was chmod 777′d before enabling permalinks and then try it again. Other sources of this error can arise from a reluctant server or one that doesn’t support mod_rewrite in Apache.. or your server doesn’t even run Apache. In this case, a visit to the WordPress Codex is in order for setting up permalinks in your special case.
Come On, Enlighten Us Already
Permalinks encourage website browsing. From a millisecond glance at a link to your permalinked blog, the user knows how recent the post is and its title. That is a lot more than /index.php?p=102 could ever convey. What if a user follows a permalink to your site only to find that you have since removed that article or changed the post slug (the last part of the permalink with the title)? They can simply navigate your archives by manipulating your URL. For example, going to http://www.paulstamatiou.com/2006/01 produces an archive page letting the user browse all of the posts I made in January, 2006. Want to see what post I made on January 21st, 2006? Just add /21 to the end of the URL.
Permalinks are vital to a successful blog. By only remembering the date of a post, people can easily spread the word about a particular post of yours. Permalinks also work for categories and tags. You can see all of my posts in the software category with a URL formatted like http://www.paulstamatiou.com/categories/software/. Also, since the actual post title is within the link itself, search engines pick up your link faster and can provide your link in higher search rankings. Tom Raftery goes more in-depth about the relationship between SEO and Permalinks.
PaulStamatiou.com runs on the Thesis Theme for WordPress
Thesis is the search engine optimized WordPress theme of choice for serious online publishers. If you’re a blogger who doesn’t understand a lot of PHP, Thesis will give a ton of functionality without having to alter any code. For the advanced, Thesis has incredible customization possibilities via Thesis hooks.
With so many design options, you can use the template over and over and never have it look like the same site. The theme is robust and flexible enough not only to accommodate a site like PaulStamatiou.com, but also to enable the site to run far more efficiently than it ever has before.
Stumble This




{ 7 trackbacks }
{ 18 comments… read them below or add one }
I would do this, and originally had my permalinks nice and neat looking, but I’m dependant on StatTraq for my decent stats. And for some reason, it stopped picking up on post counts. I don’t know what happened, but realized it would only work if I put it back to default. My host said there was nothing different on his end, so I don’t know. I’ll get my permalinks pretty again when some circumstances change.
Fabulously in-depth article Paul – well done.
Thanks for the link love too!
Tom
I’ve been missing out on this for a while. I might just try it later if my htaccess file isn’t too messed up already! :P
so what’s the down and dirty for someone who ahem is using the less than appealing permalink structure wishing to convert to the more appealing and understandable plink structure that’s mentioned in this post. how would someone go about changing the structure without breaking incoming links that are still using the old?
I’m not sure if I’m ignorant, but doesn’t Wordpress let you easily change the permalink structure without hand-editing the .htaccess file? You can find it in Options -> Permalinks.
Great post; I don’t know why I had never bothered to do this before.
To the person who asked… no, WordPress can’t do it without editing your .htaccess file. It’s pretty close, though — it will tell you what to include, and if your .htaccess is writeable (which I’m not sure is a good idea), it will actually do it for you. So in that case, yes, you don’t need to do anything, but the .htaccess is still being altered.
Thanks, Paul.
You can also use the Nice Search plugin to make your search URL’s nice.
e.g. /?s=hello+world, it’s /search/hello+world.
Hey there,
I had done some research on permalinks and found that you could actualy give them a .htm extention to make them look like actual pages.
You can see my post here
Yes, I know about giving the permalinks a file extension. The WordPress Codex page I linked to talks about it. However, it is purely aesthetic and holds no real semantic value. As in, the page is not really HTML, it’s still a concoction of php. I’m not too certain that Google will think of a page any more or less highly with or without such a file extension.
As far as my understanding of what Google gives priority to – they give priority to a page in the root of a site over a folder that is off the root.
Example –
site.com/post-title.htm
would be higher priority then
site.com/post-category/post-title
- Dan
Good point Dan. However with the /post-title.htm, you lose the advantage of knowing when the post was made, unless that is incorporated in the name.
But if i’m not mistaken, permalinks are now taken care of by Wordpress and not by apache anymore? atleast that’s what i was hearing when i asked questions like “why don’t my live archives work with the new permalinks, while they did work with the old?”
I would love to use the permalinks like you describe but when I changed it in my Wordpress settings it all seemed to work fine until I realized that my Archives links were all broken. In other words, clicking on a previous month gave me Not Found pages. I never could figure out why. I’m also sure that my .htaccess file was and is editable and I’m on a Linux/Apache server at Godaddy.com
Any suggestions?
Thank you Paul for your article.
My blog is on blogger so I will have to search a little more for help…
Thanks Paul, just set them up :-)
I need some help with my permalinks. I don’t know the first thing about .htaccess and the code behind all of this permalink-stuff. So any help would be apprecaited.
I’m currently using the default WP permalink structure.
I’d like to change the structure to: /%category%/%postname%/
When I change the structure in the permalinks admin panel and I test the pages, I get what appears to be the main page of my site. (for example, the comment now box doesn’t appear, and there are other posts on the page).
Any ideas what might be causing this?
1st time user of wordpress so bear with me….
Is there a way to change the permalink structure so that it doesn’t include the “/wordpress/” portion? The custom field still yeilds it and the “Catagory base” and “Tag base” fields don’t seem to do anything at the bottom of the screen under optional.
Any help would be great.
@patrick
hope i’m not too late for your concern..
just try to put this format for your permalink structure
/%category%/%postname%/
it helps in your search ranking.
but you can also use the format having the month and date which i think is one of the option in your wordpress