1/16/2008 ↓

Configuring WP Permalinks

Author: Jeff Chandler Category: HOW-TO

Thanks for visiting! If you're new here, you may want to subscribe to our RSS feed. This blog posts regular Wordpress news, updates of themes, plugins, ideas, hacks, quick fixes and everything about blogging, especially about Wordpress. Go ahead, subscribe to our feed! You can also receive updates from this blog via email.

Pretty Permalinks

Quite often, we hear of the terms (permalinks or pretty permalinks) which can also be called SEO-friendly URLs. These URLs are not only SEO friendly, but I believe they are human friendly as well. By default, WordPress uses URLs that look like a mishmash of letters and numbers with a few question marks mixed in for good measure. These types of links are frowned upon by search engine spiders and as a human being, they are also hard to read.

Fortunately, WordPress provides a way for us to change this linking structure to something understandable. WordPress calls these Permalinks. Permalink settings can be configured a number of different ways. One of the ways to quickly configure permalinks is by choosing one of the Common Options. These common options include:

Default - http://www.domain.com/?p=123

Date and name based - http://www.domain.com/2008/01/15/sample-post/

Numeric - http://www.domain.com/archives/123

There is no sense in using the default option so choose either Date and name based or Numeric if you don’t feel like tinkering with the Custom Structure.

The custom structure of the permalinks settings area allows you to customize the way permalinks are displayed by using any combination of the following permalink tags.

%year% - 4-digit year (for example, 2008)

%monthnum% - 2-digit month (for example, 01 for January)

%day% - 2-digit day (for example, 15)

%hour% - 2-digit hour of the day (for example, 20 for 10PM)

%minute% - 2-digit minute (for example, 50)

%second% - 2-digit second (for example, 24)

%postname% - Text separated by dashes which usually ends up being the post name. (for example, configuring-wp-permalinks)

%post_id% - The unique, numerical ID of the post (for example, 124)

%category% - The text of the category name that the post is filed in (for example, how-to)

%author% - Text of the post author’s name (for example, ronald-huereca)

Example of custom structure in use:

Custom Structure: /%year%/%monthnum%/%day%/

Link Output: http://www.domain.com/2008/01/16/

Make sure that you include the back slashes at the beginning of the custom structure, after each tag and at the end. This will ensure that WordPress writes the correct rules in the .htaccess file via mod_rewrite.

For my own blog, I seem to have done fairly well in the search engines by using the Custom Structure method and using the %postname% tag. I can’t say for sure which combination would do better or worst for search engines. The only thing I can suggest is that you configure your permalinks to look whats best for you.

*WARNING*

Changing the structure of your permalinks affects all of the permalinks on your blog. This is important to know because search engines will have indexed posts on your site via their permalinks. If you change the permalink structure mid stream, you will end up invalidating all of those links.

What to do if you don’t have a .htaccess file?

If you notice that you don’t have a .htaccess file within the same directory as your WordPress installation, you can create one by first creating a blank .txt file and saving the file as htaccess.txt. Upload this file via FTP to the same folder that houses your WordPress installation. Once the file is uploaded, set the permissions to the file as 666. Next, rename the file to .htaccess. Now you should have a blank .htaccess file for which WordPress can write the proper permalink rules to.

Servers That Don’t Use Apache Or mod_rewrite.

If the webhosting server you are on does not have the apache module mod_rewrite enabled, you can still use the permalink settings in WordPress by placing index.php in front of any custom permalink tags.

For example: /index.php/%year%/%monthnum%/%day%/

Equals: http://www.domain.com/index.php/2008/01/16/

Using index.php in this way eliminates the need for a .htaccess file.

I hope this little primer on how to configure your permalinks within WordPress was helpful. I’ve seen too many blogs out on the net that have yet to take advantage of this awesome feature. As I’ve said before, using any sort of permalink structure is better than the WP default. Not only is it beneficial in terms of SEO, but it also makes it easier for human beings to see at a glance, what a particular link is pointing to without having to visit the page.

If you use the custom structure aspect of permalinks, I’d be very interested in knowing which configuration of permalink tags you have chosen to use and why.

1 Star2 Stars3 Stars4 Stars5 Stars (19 votes, average: 4.47 out of 5)
Loading ... Loading ...
Sphere: Related Content | stumbleit |
Translate to German Translate to Spanish Translate to French Translate to Italian Translate to Portuguese Translate to Japanese Translate to Korean Translate to Russian Translate to Chinese

Latest Videos

45 Comments | Leave a comment | Comments RSS

  1. What if I wanted to change the title tag structure so it changes only the posts I submit from here on while keeping the numeric structure I’ve always had from the past posts?

    I understand I’m stuck with the numeric structure I have now since Google and others have indexed or linked to those posts like that. Or am I not really stuck?

    Emon (1 comments.) — 01/16/2008 @ 6:50 pm
  2. Emon: You don’t need to worry about it. The (pretty) permanent link structure you define is in addition to the default ?p=blah format that WordPress uses.

    Using a random post from my journal for e.g., both http://emphaticallystatic.org/earlier/the-muddy-waters/ and the default http://emphaticallystatic.org/?p=1070 will take you to the same post.

    pundit (4 comments.) — 01/16/2008 @ 7:53 pm
  3. http://perishablepress.com/press/2008/01/16/comprehensive-htaccess-canonicalization-for-wordpress/

    Permalink URL canonicalization is automated via PHP in WordPress 2.3+, however, for those of us running sites on pre-2.3 versions or preferring to deal with rewrites directly via Apache, comprehensive WordPress URL canonicalization via htaccess may seem impossible. While there are several common methods that are partially effective, there has not yet been available a complete, user-friendly solution designed specifically for WordPress. Until now..

    Peter — 01/16/2008 @ 8:14 pm
  4. it’s a good post.
    i am using only %postname% tag as you

    Alisko (1 comments.) — 01/16/2008 @ 8:53 pm
  5. What about category permalink tags?

    Keith (3 comments.) — 01/16/2008 @ 9:18 pm
  6. I deliberately skipped the category permalink tags but if you want, I can go ahead and include the information for those as well. I didn’t think those were a big deal to include.
    Jeffro2pt0 (131 comments.) — 01/16/2008 @ 10:04 pm
  7. I use the date/name option, which has worked well for my blog so far.

    PJ (1 comments.) — 01/16/2008 @ 10:30 pm
  8. Great post. I use the date and name based permalinks also, but I never liked using index.php in the permalink, but I supposed if you are not running Apache and mod_rewrite, you don’t have much of a choice.

    ulysses ronquillo (5 comments.) — 01/16/2008 @ 11:36 pm
  9. I second the request for a category-treatment, avoiding the insertion a ‘category’ dir-level. I used the Custom interface, copied the .htaccess file it rendered, uploaded it to my root, which the host allows. I had previously successfully used .htaccess customizations to do other things. But the WP-generated script (untouched by me) ’scrambled’ my URLs, and I couldn’t get it off the server fast enough. I suspect I misunderstood - though I studied multiple sources - how to build the customization-terms.
    Thanks - I don’t like my ugly URLs either! ;-)

    Ted Clayton (29 comments.) — 01/16/2008 @ 11:40 pm
  10. I’ve been using the default structure the whole time I’ve had my blog. I’ve got nearly 10,000 posts already, and found that for the type of content I use on my site, having the post ID in the permalinks works to my advantage in a way, so I never changed it.

    I’ve always been hesitant to change it from the default because I don’t want it so that you can’t get to a post without using the default way, but I guess it works anyway according to pundit…I’m kind of at an impasse as far as deciding whether I should bother using them or not.

    dave (1 comments.) — 01/17/2008 @ 12:50 am
  11. As a rookie blogger I had setup my permalink using a structure I thought that I wanted but it did not include the postname. After a few months I changed it and of course all of my linking that was already indexed by the search engines broke and everyone ended up on the home page with a not found… Word of caution if you change from a non-default permalink structure to something else. You do get re-indexed eventually but that link is out there at a lot of places besides the search engines.

    Bill (6 comments.) — 01/17/2008 @ 2:43 am
  12. I use the /%year%/%monthnum%/%day%/%postname%/ option for my blog. I’m not a superblogger now, but I figured it would be better to have a good structure in place … I can have a lot of similar post names and be ok if they’re on different days or years … always trying to think ahead :)

    Tadd (62 comments.) — 01/17/2008 @ 3:49 am
  13. Two of the most useful plugins when it comes to cleaning up wordpress url that you neglected:

    http://fortes.com/projects/wordpress/top-level-cats/ — Allows for /%category%/%postname% urls. Also makes /%category% work appropriately.

    http://urbangiraffe.com/plugins/redirection/ — SO useful. If you are using %postname% in the url then this is amazingly handy as it will let you change the post slug (url) and put a 301 in place for you. It also tracks 404’s so you can fix previously old broken links AND the redirects suport regex, so if you need to redirect an entire series of similar links to somewhere appropriate it’s useful

    Jeff (6 comments.) — 01/17/2008 @ 4:48 am
  14. I have been using a permalinks structure for a long time. How do I change the permalinks structure, AND ensure that the old permalinks will be redirected to the new one?

    LiewCF (8 comments.) — 01/17/2008 @ 6:56 am
  15. Great article! I wrote a blog post in the past about how you can enable WordPress permalinks on a Microsoft IIS Webserver using isapi rewrite. By default it’s not possible to use permalinks on IIS because IIS doesn’t support mod_rewrite.

    The post is located here:

    http://www.schoonens.nl/camiel/2007/11/27/wordpress-permalinks-on-iis-using-isapi-rewrite/

    Camiel (1 comments.) — 01/17/2008 @ 7:00 am
  16. LiewCF
    if you would like to change the permalink structure and safe your old lnks–

    you need information about:
    Redirect pernanet 301
    RedirectMatch permanent

    there are a lot of tutorials in http://www. - for dummies like me ;)

    regards
    Monika

    Monika (23 comments.) — 01/17/2008 @ 7:31 am
  17. Well, Google is indexing the default ones, I had them running for weeks now and postname seems not to works on Pages, but only on posts (tested it). Thus, I’ll stick with the old ones.

    shadaik (5 comments.) — 01/17/2008 @ 8:36 am
  18. I had struggled a lot myself in trying to get the permalink format of my choice to work on my blog. But in the end I had to give up trying it. My hosting did not allow me to define my own .htaccess file and because of that I had a lot of confusion and irritation in the beginning.

    Eventually I had to sought to the last resort of using the index.php within the permalink structure, it worked for me like a charm and I have been enjoying very much since that day :).

    Nice post.

    Dhruva Sagar (14 comments.) — 01/17/2008 @ 8:58 am
  19. Because wordpress should be as transparent as possible, I think the best alternative for your urls is the simple /%postname%

    Flo (1 comments.) — 01/17/2008 @ 11:06 am
  20. For my blog I use the permalinks with the date format. But on sites where I use Wordpress as a CMS I prefer /%category%/%postname%/ with carefully selected category names. Works fine.

    Paul (2 comments.) — 01/17/2008 @ 1:51 pm
  21. @Jeff #13 - Thanks for these plugin-links. I think these will get me on the program!

    This may a bit contrary to the spirit of this excellent topic … but after I was humiliated trying to do category permalinks, I noticed that Google was actually indexing my stuff anyway, very closely (hours). Permalinks are supposed to be good for SEO. Now, few people besides me, Google, MSN Bot, Yahoo, Inktomi, Ask Jeeves, and a stack of lessor but attentive engines know about my pages. But, I’ll tell ya … I keep an eye on it these days … Google and all the rest absolutely pound my blog. No lie.

    They just gobble up those ugly URLs! ;-)

    Ted Claytont (29 comments.) — 01/17/2008 @ 10:37 pm
  22. Thanks for the info. Being new to this game, I never quite knew what permalinks were for. Having read your article I am much better informed.

    Pryordurkin (2 comments.) — 01/18/2008 @ 8:20 am
  23. A great ideea is with html http://www.paulierco.com/2008/01/15/sample-post.html , is more optimized and indexed by google and other search engine. Permanent link ” /%year%/%monthnum%/%day%/%postname%.html “

    paulierco (1 comments.) — 01/18/2008 @ 9:25 am
  24. Dumb question but I just want to check that permalinks are only for Unix.

    Weathervane (1 comments.) — 01/18/2008 @ 2:15 pm
  25. I use %postname% also. I thought about using %category%/%postname%
    except for one problem. I have an “about” page, and another custom page, and I don’t want %category% to show up on those pages, cuz it would look dumb to say domain.com/pagename/about instead of domain.com/about so I decided to leave the %category% tag out, but I wish there was a way to make it so posts would show %category%/%postname% while pages just show up as %postname%

    bubazoo (32 comments.) — 01/19/2008 @ 11:48 pm
  26. either that, or a way to exclude a certain page from using permalinks (like my about mage) then have posts show up as %category%/%postname%
    and pages as page/%postname% in other words, more flexibility like that.

    bubazoo (32 comments.) — 01/19/2008 @ 11:51 pm
  27. @Weathervane #24 - I think not-Unix falls under the section in the lead-article under “Servers That Don’t Use Apache Or mod_rewrite.” The options are hemmed in by an additional requirement, but still does it.

    Ted Clayton (29 comments.) — 01/20/2008 @ 12:03 am
  28. You could manually put rewrite rules in your htaccess file to exclude %category% from your static pages like your about page.

    Paul (2 comments.) — 01/20/2008 @ 1:07 am
  29. Perhaps you could also edit the PAGESLUG for those, or maybe the easiest way would be to go with Paul’s suggestion and manually including the rules in the .htaccess file.
    Jeffro2pt0 (131 comments.) — 01/20/2008 @ 7:06 am
  30. Be aware of using the %category% in custom permalinks: http://trac.wordpress.org/ticket/4699

    Gazza (1 comments.) — 01/20/2008 @ 11:27 am
  31. @Gazza #30 - Thanks for the illuminating trac-ticket link.
    For WordPress sites that are more blog-styled, the date-based permalinks seem to be a good option. For sites that are more CMS-like, and using Categories to organize access to content … it seems more a work in progress. ;-)
    Two points. 1.) Inserting an extra, ‘non-functional’ directory-layer in the form of my-domain/category/category-1, appears to me to be “unsemantic”. It looks - logically - the same as the sophomoric web-tyro error of making a subdirectory for the homepage, and using my-domain/homepage/index.htm. Superfluous, and implies a semantic relation that is both spurious & nonexistent.
    2.), worse, really, is that we can assign a post or other entry to multiple categories - and this is a good & attractive thing. Yet, when forming a permalink, only a single category-membership can be used. If we are going to give content-items membership in multiple categories, we create a basic logic-problem for permalinks. Presently, this appears to be resolved as a ‘race’ - whichever category-ID is encountered first becomes the permalink. That can easily upend & confuse intended hierarchical relationships.
    2a.) The flexibility of category-assignment is important to me. I intend to reorganize my material from time-to-time. Much of my site-organization is impermanent, by design.
    ID-numbers - the real permanent links - are admittedly ugly, but they are semantically valid.
    These comments pertain more to those using WordPress in it’s CMS incarnation, and much less to typical blogs.

    Ted Clayton (29 comments.) — 01/20/2008 @ 12:36 pm
  32. If you want to change your permalink structure there is a good plugin which 301s all your old url’s with the new ones

    http://www.deanlee.cn/wordpress/permalinks-migration-plugin/

    Shark (1 comments.) — 01/22/2008 @ 7:11 am
  33. Daring Fireball has a great article about designing permalinks carefully here.

    I use the standard y/m/d/title structure, though I have made use of post id’s in pretty urls when building sites that will be in other languages like Bangla, Arabic and Farsi, as titles in those languages create permalinks with raw UTF codes, which is VERY human-unfriendly.

    jeremyclarke (2 comments.) — 01/22/2008 @ 1:42 pm
  34. I have always preferred using custom permalinks with .html appended.
    what is the best solution to recover the search engine links if you change permalinks by design or otherwise

    Schanie (1 comments.) — 01/26/2008 @ 5:10 pm
  35. Wow, lots of discussion here. I always preferred the post id style of permalinks, it seems short, sweet and simple, unlike some of the other styles that end up wrapping onto another line. Does it really make that much difference with the search engines anymore? I have several family history blogs that get a lot of search engine traffic and use the post ID permalink structure.

    patty (1 comments.) — 01/30/2008 @ 2:12 am
  36. I use the ugly default. Longer names are bad in my opinion because some email programs won’t carry the link to pick up URL’s that wrap to another line. That’s a real concern when people email a link to a post.

    Mark (1 comments.) — 02/1/2008 @ 12:54 pm
  37. [...] este artigo do Jeffro2pt0 no site Weblog Tools Collection mais elaborado onde explica as várias opções que [...]

  38. [...] Press - Comprehensive URL Canonicalization via htaccess for WordPress-Powered Sites”, Weblog Tools Collection - Configuring WP Permalinks, and Mark Jaquith - WordPress 2.3: Canonical [...]

  39. [...] ???Weblog Tools Collection [...]

  40. [...] this plugin has a security issue, when its fixed I’ll reinstate the link. Thanks Miriam). 28. Configuring WP Permalinks. 29. WP User Manager. 30. WP Tags to Technorati [...]

  41. Alright…I tried doing all this word for word and I can’t get anything to work. Not even the other preset ones from wordpress. I made a .htaccess file, but it didn’t work. I changed permissions to let wordpress do this, but again no luck. Forgive my ignorance, but my server is MySQL is that different than apache? I read the wordpress post about permalinks so many times, but when I make them apart from the default the pages don’t show up.

    Please help!
    Thanks
    Dustin

    dustin (1 comments.) — 03/2/2008 @ 3:52 pm
  42. [...] Weblog tools Collection -Configuring WP Permalinks [...]

  43. [...] nos posibilita el uso de algo similar. Quizas muchos lo estén usando sin saberlo y otros como yo, lo desconocían. Pero me parece una idea genial y que todo el mundo debería tener la posibilidad de mejorar su SEO [...]

  44. Thanks for the post! You saved my life!

    My current webhosting not accept access to .htaccess, then the third alternative I was very useful thanks again.

    Mateus — 03/8/2008 @ 11:51 pm
  45. [...] Configuring WP Permalinks- Weblog Tools Collection has a useful guide on setting up permalinks on your WordPress blog and how [...]

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required, will not be published)


S2