WordPress’s default behavior for permalinks is to create a URL that looks something like this:

http://www.yoursite.com/index.php?p=2

where p is the post id.

If you care at all about the search engines indexing your blog, and you should if you want anyone to read it :), you’ll want to use a little SEO (search engine optimization) trick by having nice, neat URLs that describe your post.

In my case, I wanted my individual post archives to be in the root of my domain, as search engines like Google devalue a page the deeper it is into the site. I also wanted the link title be the post’s name, so that my permalinks will look like this: http://www.yoursite.com/this-is-my-posts-title.htm

To do it:

You will need to have an .htaccess file and make it editable by WP. Sounds hard, but WordPress makes it easy. First of all, if you don’t know what it is, an .htaccess file is simply a text file that can contain instructions for the webserver. If you have an .htaccess file already, great. If you don’t have an .htaccess file, you’ll need to create a text file using any text editor (notepad will do) that simply has a blank page and upload it to your server. You will then need to change the properties of the .htaccess file on the server, most easily done with the same FTP program you probably used to upload wordpress to your server as well as your themes, the .htaccess files, etc. What you’re wanting to do is make the file writable. This can be accomplished by doing a chmod on the .htaccess file (many FTP programs offer this when you right click on the file -they give you an option of chmod or sometimes it is referred to as properties. So chmod the .htaccess file to 666 to make the file writable so that WordPress can edit it by itself to update the permalink structure. (If you don’t want to make the .htaccess writable by the server, then when you’re done setting up the Permalink structure WordPress will tell you what code to insert into your .htaccess file yourself using a text editor)

- log into WordPress, and then click on ‘Options’. Next click the sub-category under options entitled ‘Permalink’

- the page you’re on will now describe all the fields you can use to create your permalink. I only cared about the post name so in the edit box just underneath where it says, ‘Use the template tags above to create a virtual site structure:’ I typed the following:

/%postname%.htm

NOTE: for faster performance, it is better to include a unique variable such as the post ID number within the permalink structure If you choose to go this route, you could setup your permalinks as follows:

/%postname%-%post_id%.htm

or

/%post_id%/%postname%/

or

/%post_id%/%postname%.htm

- at this point you should click the button to Update Permalink Structure.

So now, my first WordPress post on my Tool Reviews Site can be found at http://www.toolreviews.biz/porter-cable-cffn250n-finish-brad-nailer-combo-kit.htm (btw - that post is more of a placeholder while evaluating WordPress than anything else..)

Personal Opinion Warning: Some sites have recommended including the category as part of the permalink, but this will slow down wordpress performance because many of your posts are likely to have more than one category so it can get confusing as to figure out which category WP will choose for your permalink.

The best time to set up ‘Pretty Permalinks’ is the moment you install your blog because if you already have a bunch of existing posts, changing the permalink structure will make it so that your old links to those posts will result in page not found errors - to fix this you would need to edit the .htaccess file to set up permanent redirects for each post and page in the form of:

Redirect 301 http://www.yoursite.com/index.php?p=2 http://www.yoursite.com/the-new-post-title.htm

This way people who have linked to your old URLs will get automatically redirected to the current page URL.

This all sounds WAY more complicated than it actually is when you follow the instructions step by step so don’t be overwhelmed - you can do it!

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • TwitThis
  • Share/Save/Bookmark

95 Responses to “How to configure WordPress to create search engine friendly URLs for permalinks”

  1. Good site. Thank you:-)

  2. Bill Amberg says:

    Good site. Thanks!

  3. [...] For more information about why you should use custom permalinks look here or here. [...]

  4. Counter says:

    Thank you so much. I’ve just used this inf0 to get permalinks working on my latest site.

    Great stuff!!

  5. Prashant says:

    your post is great and i have done the changes but i am facing one problem.. my trackback links show

    http://www.styleikon.com/an-im...../trackback

    instead of http://www.styleikon.com/an-impressionable-age.htm

    why does it add “trackback” at the end of the link??

  6. Tobin Hunt says:

    Wow, thank you so much, finally an explanation in layman’s terms (or layperson if you prefer!). My permalinks are SEARCH ENGINE FRIENDLY - YIPPEE!!

    Had some tricky moments where I accidentally made my whole blog password protected with an htaccess mistake, but I’m still learning.

  7. Steve Green says:

    Hey this is a great post even for newbies.
    I’m just considering moving from Blogger to Wordpress on my Hosting server.
    As a new blogger. I’m presuming that it’s better to get all this stuff setup before posting for the very first time, to aviod the pitfalls?

    Does anyone kknow if it’s possible to “export” my whole blog from Blogger to Wordpress?

    Thanks
    Steve

  8. John Pools says:

    I’ve added permalinks to my wordpress blog, and they seem to be working fine. One thing that bothers me is that when you click into a post the url still shows an ID number. Note the (7) in the following URL: http://www.swimming-pool-store.....-supplies/

    I realise that this seven corresponds to the order in which the post was made. Is it possible to remove these numbers? Or have I made a mistake when I installed permalinks?

    Thanks

    John

  9. Dan says:

    Thanks, works great for me on one of the sites I’m playing around with. Really simple solution to set up.

  10. Ahamed says:

    Thanks for the guide.

    I need help on :

    1) The title of the page to contain the post subject. How to modify the theme?

    2) Archive Month links are showing only http://mywebdomain.com/%postname

    Thank you

  11. Kamran says:

    Here is the fix for page not found problem , “The requested URL /blog/archives/testing-wordpress/ was not found on this server.” More info can be found at http://www.kamranzaidi.com

    You have to unable the mod_rewrite in your apache http.conf file. Step 1: Go to your apache conf directory , $APACHE/apache/conf
    Step 2: Edit httpd.conf file.
    Step 3: Search for “Dynamic Shared Object (DSO) Support” section
    Step 4: Unable loading of rewrite mod by removing # sign from this line LoadModule rewrite_module modules/mod_rewrite.so
    Step 5: Search for “AddModule mod_rewrite.c” and unable it by removing # sign.
    Step 6: save and restart your apache server.
    Step 7: Try again , now you should be able to view pages

    Hopefully it ll work.

    Thanks

  12. Douglas Seib says:

    Only thing not working now is archives -
    I get 404.

    The requested URL /2006/09/ was not found on this server.

    Categories and pages both - pages give the /title/

    the URL for this custom wordpress blog is at client’s http://www.electronicsleader.net

  13. Thanks, I was looking for this!

  14. Webbdesign says:

    Great tutorial!

  15. aukc says:

    Thanks for informaton, this is the first time to I see the content of the .htaccess file. I never bothered about it before I read your post.

    I don’t know anything about .htaccess files but managed to set the permalinks using WP control panel. Is it neccessary or advisable to mess around with the .htaccess file?

  16. I have an important question, maybe this post is quite old but i want fancy URL like domain.com/something-myblog. but currently it appears something like /?=234 but i don’t want like this. So what i did is i copied the above lines to my .htaccess file, but question is here i’m using new WP version and i don’t have above option in admin .. permalinks. Please advice what should i do to avail that feature? Thanks

  17. Aftonbladhet says:

    Syed Networks: Try this

    # BEGIN WordPress

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

    # END WordPress

  18. Kiviniar says:

    Hugs and kisses……

    Its working…thanks a ton

    Regards
    Kiviniar

    p.s.i can sleep a relieved man

  19. [...] I figured out the link problem, after the update I made a few changes according to this tutorial Word Press for Newbies by Elliot Back. Anyhow I used the code he talks about to activate pretty links, and for some reason all my links now gave me a 404 error, so I followed the instructions on this page instead. [...]

  20. Thanks, works great for me on my site.
    Great post.

  21. [...] Anyway, I just had to put /%postname%.htm to make my urls to include the title of the post. It worked by just doing so. No edit required in .htaccess as it is mentioned in couple of resources on the web (Click Here). [...]

  22. Sabah Drabu says:

    I was using the default option of wordpress, till web savvy friend pointed out that I should make my blog SEO friendly. Found you through the wordpress codex.
    Thanks for the .htaccess file, I was could not cook that up!

  23. Mark says:

    previously my permalink structure is something like /%category%/%postname%/
    and i want to change it to /%postname%/ only, how can i do that such that old post should be redirected to the new one.

  24. [...] How to configure WordPress to create search engine friendly URLs for permalinks [...]

  25. [...] Next came the Search Engine Friendly (SEF) URLs which are the URLs that excludes unfriendly items to search engine such as ‘%’, ‘?’, ‘=’, ‘%’. In WordPress, Default URLs are in the form of as http://www.domain.com/index.php?p=2 where p is the post id.  In order to make these URLs Search Engine Friendly, I took my favorite route, I did google and found the article: How to configure WordPress to create search engine friendly URLs for permalinks [...]

  26. evilryan says:

    I’m just starting to tinker with this stuff, this post has been extremely helpful. THANKS!

  27. Bill Dexter says:

    Thanks for the info, Emily. One question: how did you manage to put the number of readers by Feed Burner into Wordpress?

  28. Sabri Arslan says:

    hello. i’m used
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    on my wordpress mu v1.0 it’s working but subdirectories images not shown and i used users have a symbolic subdirectory. but not working.

    i tried also
    RewriteEngine On
    RewriteBase /
    RewriteRule ^category/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?category_name=$1&feed=$2 [QSA]
    RewriteRule ^category/?(.*) /index.php?category_name=$1 [QSA]
    RewriteRule ^author/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?author_name=$1&feed=$2 [QSA]
    RewriteRule ^author/?(.*) /index.php?author_name=$1 [QSA]
    RewriteRule ^([_0-9a-z-]+).htm([0-9]+)?/?$ /index.php?name=$1&page=$2 [QSA]
    RewriteRule ^([_0-9a-z-]+).htm/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?name=$1&feed=$2 [QSA]
    RewriteRule ^([_0-9a-z-]+).htm/trackback/?$ /wp-trackback.php?name=$1 [QSA]
    RewriteRule ^feed/?([_0-9a-z-]+)?/?$ /wp-feed.php?feed=$1 [QSA]
    RewriteRule ^comments/feed/?([_0-9a-z-]+)?/?$ /wp-feed.php?feed=$1&withcomments=1 [QSA]

    but not working for my blog system.

    i don’t understand mu.
    thank you

  29. Albert says:

    Very helpful. Thanks a lot. I’m new to wordpress so I need all the tips I can get. I’m now going to scour your site for answers to other questions I have.

    Albert
    http://laowaichinese.net

    PS: the leave a comment form is very confusing. I wasn’t sure what goes where…

  30. Gavriel says:

    I’m using the E-commerce plugin from http://www.instinct.co.nz/e-commerce/16 and I’d like to change it to use permalinks.

    For example instead of:
    catalog?category=4
    the link would be
    catalog/caregory_slug

    I’ve already changed the code, so the links are shown this way, I added to every category a slug in the DB.

    The problem is that I don’t know what to change in the .htaccess or WP code in order to tell WP that all the URLs that match ^catalog/ should be treated as it was catalog?…

    This is what I tried:
    RewriteRule ^catalog/([^/]*)/?$ /catalog?category_slug=$1 [L]
    RewriteRule ^catalog/([^/]*)/([^/]*)/?$ /catalog?category_slug=$1&subcategory_slug=$2 [L]

    Even when I try the next rule for testing:
    RewriteRule ^catalog/([^/]*)/([^/]*)/?$ /index.php?p=4&category_slug=$1&subcategory_slug=$2 [L]

    I get the default error page: Sorry, but you are looking for something that isn’t here.

    I’d really appriciate any help / hint / example to see how can I hack WP to use permalinks in this case.

  31. Manu says:

    Great Sruff!

    Thanks…….

  32. Arif Mahmood says:

    It is wrong that the search engines dont crawl deeper pages. The crawling is totally depending on your linking structures. One of an example is about.com. Beside this there are many other references which proves that the search engine crawler can crawl deeply. It totally depends on your link structure. Suppose you give the links of your deeper pages at your home page then the crawler must crawl these pages following the links. The crawler follows the link not the pages hierarchy. At the end i must say in your permalink if you choose the structures or tags which have key words then it would be an advantage.

  33. Zeus Web Sever Request Rewriting->Enabling Request Rewriting Enabled
    Rewrite Script

    Enter the rewrite script here:
    RULE_0_START:
    match URL into $ with /category/(.*)/(feed|rdf|rss|rss2|atom)/?$
    if not matched then goto RULE_0_END
    set URL = /wp-feed.php?category_name=$1&feed=$2
    goto END
    RULE_0_END:

    RULE_1_START:
    #match URL into $ with /category/([_a-z-]+\/)+$
    match URL into $ with /category/?(.*)
    if not matched then goto RULE_1_END
    set URL = /index.php?category_name=$1
    goto END
    RULE_1_END:

    RULE_2_START:
    match URL into $ with /author/(.*)/(feed|rdf|rss|rss2|atom)/?$
    if not matched then goto RULE_2_END
    set URL = /wp-feed.php?author_name=$1&feed=$2
    goto END
    RULE_2_END:

    RULE_3_START:
    match URL into $ with author/?(.*)
    if not matched then goto RULE_3_END
    set URL = /index.php?author_name=$1
    goto END
    RULE_3_END:

    RULE_4_START:
    match URL into $ with ([_0-9a-z-]+).html([0-9]+)?/?$
    if not matched then goto RULE_4_END
    set URL = /index.php?name=$1&page=$2
    goto END
    RULE_4_END:

    RULE_5_START:
    match URL into $ with ([_0-9a-z-]+).html/(feed|rdf|rss|rss2|atom)/?$
    if not matched then goto RULE_5_END
    set URL = /wp-feed.php?name=$1&feed=$2
    goto END
    RULE_5_END:

    RULE_6_START:
    match URL into $ with ([_0-9a-z-]+).html/trackback/?$
    if not matched then goto RULE_6_END
    set URL = /wp-trackback.php?name=$1
    goto END
    RULE_6_END:

    RULE_7_START:
    match URL into $ with comments/feed/?([_0-9a-z-]+)?/?$
    if not matched then goto RULE_7_END
    set URL = /wp-feed.php?feed=$1&withcomments=1
    goto END
    RULE_7_END:

    RULE_8_START:
    match URL into $ with feed/?([_0-9a-z-]+)?/?$
    if not matched then goto RULE_8_END
    set URL = /wp-feed.php?feed=$1
    goto END
    RULE_8_END:

    RULE_11_START:
    match URL into $ with ([0-9]+)\/([0-9]+)\/(([0-9]+)\/)?$
    if not matched then goto RULE_11_END
    set URL = /index.php?m=$1$2$3
    goto END
    RULE_11_END:

  34. ramakrishna says:

    Iam using wordpress2. In this blog you mentioned “Use the template tags above to create a virtual site structure”. But I do not have this option. The options I have : Options>>permalinks andunder permalinis there are two catagories: (1) Common Options (2) Optional. Under (1) Common Options the edit options are:
    __________________________________
    Default
    http://www.yoursitename.com/?p=123
    __________________________________
    Date and name based
    http://www.yoursitename.com/in.....mple-post/
    __________________________________
    Numeric
    http://www.yoursitename.com/index.php/archives/123
    __________________________________
    Custom, specify below
    __________________________________
    Under Optional:
    Catagory Base
    __________________________________
    I could not see the sentence “Use the template tags above to create a virtual site structure” to edit with /%postname%.htm

    Can you please guide me?
    Thanks and regards.

  35. Ben Grinnell says:

    Worked like a charm! Thanks so much Emily, working on my second post at http://www.337design.com/blog.

    Is it better for SEO reasons to put it at blog.337design.com? Thanks for your help, Ben

  36. [...] How to configure WordPress to create search engine friendly URLs for permalinks [...]

  37. Maki says:

    Hi! .. I was just wondering, why did you insert .htm behind the postname?

    I’ve seen many people just use /%postname%/ alone.

    Is there any difference?

  38. Nice Article, but this is now deprecated in favor of using the following and having wordpress take over.

    # BEGIN WordPress

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

    # END WordPress

    http://www.askapache.com/2006/.....ticle.html

  39. Shahzad says:

    Thankyou very much for putting this up, I was actually looking for a permalinks solution, and it turned out this was the one thing I was after !
    thanks a bunch !

    peace
    -mE

  40. Shoukath says:

    Hi,
    how to rewrite the mod wp for my blog without losing the previous feeds?

    my blog

    my blog on Home Based Business

  41. [...] 2. Setting permalinks: pakai  format /keyword1/%category%/%postname%.keyword2 Ganti “keyword1″ dan “keyword2″ (tanpa quote) dengan keyword yang ditembak Misalnya situs mas tentang “blue widget tools”, maka yang harus ditulis /blue-widget/%category%/%postname%.tools atau standarnya ini aja: /%category%/%postname%.html (copy paste tulisan disebelah apa adanya). Sebelum merubah permalinks, rubah CHMOD file .htaccess ke 777 sumber ada di sini, sini, sini, dan sini 3. Update isian di menu Option –> Write –> Update Service Standarnya berisi rpc.pingomatic.com, sebenarnya ini aja udah cukup sih.. karena pingomatic memforward pingnya ke puluhan pinglist, tapi kalau mau lebih mantap lagi ya tambahin daftarnya. Daftar ping search ndiri aja ya… Oh ya, semakin banyak pinglist yang kita isikan, semakin lambat (lelet) waktu yang digunakan pada saat kita posting dan klik “publish”. [...]

  42. WebbyDiva says:

    Thank you so much! I looked for an explanation of the permalinks in WordPress and found your instructions .. very thorough and easy to follow. Thanks again !

  43. James Kooi says:

    Very helpful, I went with post name and post id followed by .htm

    Thank you for clarifying a few things for me that aren’t so clear in the wordpress codex, wish i would have ended up here first off.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>