How to configure WordPress to create search engine friendly URLs for permalinks

facebook How to configure WordPress to create search engine friendly URLs for permalinkstwitter How to configure WordPress to create search engine friendly URLs for permalinksgoogle plus How to configure WordPress to create search engine friendly URLs for permalinksreddit How to configure WordPress to create search engine friendly URLs for permalinkspinterest How to configure WordPress to create search engine friendly URLs for permalinkslinkedin How to configure WordPress to create search engine friendly URLs for permalinksmail How to configure WordPress to create search engine friendly URLs for permalinks

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!

facebook How to configure WordPress to create search engine friendly URLs for permalinkstwitter How to configure WordPress to create search engine friendly URLs for permalinksgoogle plus How to configure WordPress to create search engine friendly URLs for permalinksreddit How to configure WordPress to create search engine friendly URLs for permalinkspinterest How to configure WordPress to create search engine friendly URLs for permalinkslinkedin How to configure WordPress to create search engine friendly URLs for permalinksmail How to configure WordPress to create search engine friendly URLs for permalinks

67 thoughts on “How to configure WordPress to create search engine friendly URLs for permalinks

  1. Thank you soooo much for this page! I’ve spent the past two or so weeks really studying blogware options, as I want to move away from blogger.com. While I’m quite comfortable with handcoding HTML & CSS, validating, and even customizing a few perl scripts, the blog world is new to me, in the hands-on sense. WP seemed to be a great choice, but I despised the no-information-given URLs it creates. Your page perfectly responds to that concern.

    Now, if I can just get up the heart to delve into the unknown (to me) world of php and mySQL. Fortunately, my (new) host, Pair Networks, has the required software in place. I’ll do some more reading about the basics, so come Labor Day weekend, I can take a huge cup of coffee, and dig in. By then, I *should* have made the final choice between b2evolution and wordpress.

    I owe ya one! Thanks again.

    pam

  2. Thank you, I tried it on an WP blog I maintain and it works. Just did as you write and put the .htaccess in the document root, which in my case is not the wordpress directory.

    If you care you can find it here: http://www.reister.org. Its my family design and sculpture activity.

  3. One item to note, if you have links to individual posts either in your blog or from other sites, editting the .htaccess may cause those links to be broken if you have editted the permalinks in the past. I would recommended that you add in the additional lines rather than a replacing the file completely. That seemed to work better on my site it in my site.
    Mark

  4. /%postname%.htm

    I added the above code in my permalink setting and entered the generated code to an htaccess file.

    i added some new posts to the blog since completing the steps above.

    the problem is i seem to have blown up my wp blog. what ever link in the post i click — post title, comment, — the page isn’t found. i can’t add comments to posts anymore.

    it’s a new blog — my first one.
    ne1 know what i must do to fix this problem?

  5. I wanted to impliment this because I feel it would be much better. It worked fine until I clicked on my categories. I found that my template was thrown into chaos and since I’m a newbie at all this, I didn’t know how to fix the problem and had to revert back to the default.

    Do you have any idea what went wrong, and how I can fix it?

  6. Thanks for this way. But when I click any of my post, getting the following error:

    Not Found
    The requested URL /wp/toyota-expert-says-high-volume-hydrogen-powered-fuel-cell-cars-at-least-25-years-away.htm was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

  7. I tried this, it works – except for when it is listing all the months – wordpress no longer shows the link (www.example-site.com/archives/10/03) – instead it just shows (www.example-site.com/archives).

    How do I fix this?

  8. Not sure what the .htaccess is for (color me duh I’m blushing) but i ended up deleting it to get this to work. The links work fine but when I click on the permalink, it breaks all the graphics (which may explain what the .htaccess is for LOL……..

  9. what about other linking fucnctions… my wordpress was linking with index.html?m=22341235 etc, now they are all gone :P

    Help please

  10. Pingback: Abi Studios

  11. Hi,

    Even I had seen many answers, I couldn’t find the way to my server to work with friendly URLs.

    This is the error I am getting everytime.

    500 Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    Apache/2.0.48 Server at http://www.XXXXXX.net Port 80

  12. Hi,
    I’ve installed wordpress and used this structure
    /archives/%postname%/

    and wrote a test post titled – testing WordPress

    The permalink generated is
    http://www.mysite.com/blog/archives/testing-wordpress/

    but when you click on it an error is generated saying

    “The requested URL /blog/archives/testing-wordpress/ was not found on this server.”

    What could be the problem. Please advise

    Gerald

  13. Thanks for the guide.

    I’m using the custom setting and everything seems to work fine including the category option. The only problem seems to be the Title on top. It looks like this:

    Site name >> Blog Archives >> Custom Title

    Even though I post new articles/news/blogs the word ‘Blog Archives’ continue to appear on Title of the page. Can this be done away with? I want it to look like this:

    Site name >> Custom Title

    Thank you in advance!

  14. Updated the links to your article. All the best for your new blog home.

    Sadly I did not manage to get across the .htaccess limitation on yahoo. It is just plain silly and annoying. Do not have enough time to cancel my account with yahoo and shift to some other provider, and hence, will have to make do with this as of now, and home yahoo allows .htaccess files or wordpress comes up with an alternate way of managing permalinks.

  15. Emily – you mentioned using /%postname%.htm
    Does this apply for WP 2 also

    I ask because I had the option to check:

    /%year%/%monthnum%/%day%/%postname%/

    Do I still place your rewrite code in the .htacess file for it to work (it was not created with the installation)?

    Do I include the[QSA] at the bottom of your code?

    Thanks

  16. Thank You soooo much, I have been trying for weeks to get this figured out. You are a GODSEND! Smart and Good Looking. Just read your about me page. Same health experiences, I feel your pain. Keep smilin’!

  17. Pingback: SIG Master Blog

  18. 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.

  19. 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

  20. 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.com/supplies/7/swimming-pool-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

  21. 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

  22. 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?

  23. Pingback: A Fun Blog on Everything » Permalinks for WordPress - Mod Rewrite code

  24. 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!

  25. Pingback: MyCorollories » My Experiences with WordPress

  26. 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.

  27. 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:

  28. Pingback: Setting Permalink Yang SE-Friendly di Wordpress | Cosa Aranda - NEW

  29. 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?

    • I think using the .htm after the postname gives a slight SEO benefit (the links that come in are to the same folder, thus adding some weight to the value of that folder instead of spreading it out across subfolders)

  30. 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

  31. 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.

  32. To the last few commentors: This post is a few years old, so some of it is outdated and easier to do with newer WP versions and plugins.

    To Yan: The extensions (.htm) and (.html) are the same thing, it’s just that older computers only allowed 3 character extensions to identify what type of file it is and which programs could access it.

    I’m not sure when, but some programs started using 4, and since it has 4 words(hyper text markup language), they started using (.html). I think they’re are semi-compatible, where you can stop at htm on a html page, but not the other way around, but don’t quote me.

    B)>

  33. hi
    i am new one to php..
    now i develop my site using word press.
    but i want create my own coding, i want detail about php -permalink.
    pls help., me send samples .
    thank .
    team
    ‘tamilofun ‘

  34. I’m not new to htaccess or anything, but I just couldn’t figure out how to do this seemingly simple procedure in WordPress. Thank you for your easy to understand post!

  35. Thanks
    it was more useful than WordPress codex.
    I had changed my site, and worked perfect.

    except with using %post_id%. It didn’t work for my old posts. but I removed it and used “/%category%/%postname%.htm”.
    It works and it seems that it solves the after setup permalink change problem.

  36. Pingback: 使用固定链接

  37. Pingback: WordPress固定链接的设置方法 让Nginx支持WordPress的固定链接 | 新的网

  38. Pingback: mod_rewrite di IIS 6 |

Leave a Reply

Your email address will not be published. Required fields are marked *

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