Permalinks are pretty

QR:  Permalinks are pretty

[Original article source: JamesICT]

Permalinks often confuse people and this is probably because the term may sound a bit technical when first getting started with WordPress. However, when you think about it, the name does explain their purpose. It simply makes the ‘link’ in the url a pretty ‘permanent’ one. For example, without permalinks a default WordPress post would look like this: ‘http://jamesict.com/?p=2?. And as you can see, it is not exactly pretty is it? So, the alternative is to set the permalinks into action which will change the url completely.
Now the thing is, it can be set in many ways, with the most common one in use being to set the year/month and post name as the path in the url. This means that a post titled Permalinks are Pretty would become ‘http://jamesict.com/2008/11/permalinks-are-pretty’. The choice of inclusion in the permalink of the year and the month is so that if you have another post of the same name, say 2 years down the track when you have thousands of posts and cannot remember all the names, you will not produce a duplicate post with the same permalink. All makes perfect sense when you think about it.

So that explains what a permalink is and what it does. The next step is to work out how to actually set them in motion.

Unfortunately, this is where it takes a twist and turn and things get a little bit more tricky. Setting the permalinks structure via the admin panel – Settings – Permalinks, is easy enough, but when you first attempt to do this, it will not work. And yes, there is a perfectly good reason as to why not. You see, when you make this adjustment, the structure change tries to write some code to a particular file and the problem is [especially if you have a new WordPress default install], it is most likely you do not have this file at all. It is called .htaccess and is nothing more than a simple txt file with it’s only purpose being that it will include little bits of code that will be server specific and make such things as permalinks work. it’s to do with something called mod_rewrite, but I’ll let you read all about that in the Codex if it really interests you that much.

The point here is that it is very easy to make a .htaccess file. It can be done in virtually any text editor by opening a new file and then saving it as .htaccess. Notice there is nothing in front of ‘.’ and don’t worry, this is not a typo. and no, no need to write anything whatsoever in the file. Trust me – it’s not necessary.

So you make this file and the next step is to get it online. Again, tricky if you have never used something called FTP, but remarkably easy if you have. All you need to do is upload your .htaccess file to where your WordPress root files reside on your server. If you are not sure where this may be, just look for the location where there are lots of files all beginning with ‘wp-’ and drop in the same directory on your server. That’s that then? No, not quite, but almost.

This particular file needs to be written to when you make the changes via your admin panel, as mentioned above, and in order for this to happen, you need to give the file some special permissions. Again, this can be server specific, but more often than not, you can give it a permission of 777 [using your FTP program will accomplish this task] and then make the changes to your permalink structure in your admin panel. This is a security risk though, so as soon as you have made the changes, you should go back into your FTP and set the permissions back to something like 644. This will keep it safe enough from anyone doing any damage should they be of a ‘hacking’ character and inclined to be nasty to your and all your family.

In conclusion then, making the changes required to set your site to permalinks, is easy enough, but does require a few steps. The good news is that once it is done, you will probably not have to touch them again for as long as you wish to keep your site this way.

If you decide this is all too hard, just get in touch and I will give you a hand…

Leave a Reply