Jim Westergren
A blog about me, my projects, SEO, Web Development and Personal Development.
"If we did all the things we are capable of, we would literally astound ourselves." - Thomas A. Edison

WordPress users – sharpen your URLs with Google!

Update: October 1, 2009

This article is from january 2006. In new versions of WordPress all the things in this article is being taken care of automatically. DO NOT USE IT ANYMORE.


First of all you must enable the permalinks, but that you probably already have done.

Now to the point. Did you know that these are all different URLs for the same blog post?

http://www.myblog.com/my-blog-post
http://www.myblog.com/my-blog-post/
http://myblog.com/my-blog-post
http://myblog.com/my-blog-post/

Google sees this as 4 different URLs and 4 different pages when in fact it is only one. One of them will rank higher in Google than the rest. This is called canonicalization problem and is discussed by a Google staff here.

Let’s say you get a nice link to http://www.myblog.com/my-blog-post but in fact it is http://www.myblog.com/my-blog-post/ that ranks higher. This link is useless in terms of ranking!

The solution to get all 4 versions made into only one and to have all weight/power transferred to that one

Add the following lines in the .htaccess file before the WordPress permalinks lines:

Options +Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^myblog\.com
RewriteRule ^(.*)$ http://www.myblog.com/$1 [R=permanent,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.myblog.com/$1/ [L,R=301]

That will make all posts go to this version: http://www.myblog.com/my-blog-post/

Just replace myblog before you add it and don’t forget to still include the WordPress permalinks section in the .htaccess file.

Let me know any feedback, ideas, comments etc.

Update, November 28 2006

If this does not work or you use the non-www version for your blog you should use the solution provided by Christer Edwards on the comment here.

Tweet this! Boomark This! Subscribe to the RSS feed
About the Author Jim Westergren Jim Westergren is a company owner from Sweden who lives together with his wife and son. Some of his interests are SEO, web development, writing and taking photos. Read his full about page or contact him. Follow Jim on Twitter or subscribe to this blog.
In Swedish: presentation, blog.
116 responses »Leave a comment
  1. Marcus
    said on January 24, 2006 at 2:48 pm

    Great post Jim!
    I used it! :)

  2. mazhar
    said on February 3, 2006 at 3:20 pm

    hi.
    wow! real imp info. but could you please let me know wether such a trick can be done for a blogger account.

  3. Jim Westergren
    said on February 3, 2006 at 5:39 pm

    Hmm. Sorry I don’t know how blogger works. I think WordPress is better.

    By the way, yes it is important info. Please tell your friends or blog a link to me :)

  4. Russell
    said on February 12, 2006 at 7:01 am

    Would this code have to be modified if I was using the Subster Rejuvenation plugin to use wildcard dns to make post category a subdomain?

  5. Jim Westergren
    said on February 12, 2006 at 3:35 pm

    Russell,

    Oh, that I cannot answer to. But if your WordPress post URLs look like the ones above you could try it and see if it works.

    Also would be nice if you commented back here on how it went :)

  6. Nata
    said on March 9, 2006 at 7:13 pm

    Excellent article !

  7. Max
    said on March 30, 2006 at 3:06 pm

    Looking for information and found it at this great blog!
    Thanks!

  8. Maxell
    said on April 5, 2006 at 6:29 pm

    Hello! Cool blog, interesting information! Great work, very useful. Thanks you!

  9. Timberlend
    said on April 7, 2006 at 6:56 pm

    Hello!Very nice, beautiful and interesting blog!I enjoy reading your blog … keep it up guys! Respect you!My site: http://handbags.irishost.net

  10. Dave
    said on April 17, 2006 at 12:02 am

    You have a nice blog, I’m visiting it every week. But I swear I saw the same design on Webhosting site a few months ago. Is design for your site 100% made by you?

  11. Jim Westergren
    said on April 17, 2006 at 2:47 am

    Dave,

    if you see on the footer there is credits to:
    http://www.mystical-twilight.com/

    She made it originally and a few other ones has it as well.

  12. Socrat888
    said on April 24, 2006 at 11:37 am

    Thank’s Great post

  13. Devang Barot
    said on May 15, 2006 at 12:15 pm

    Looks Good website
    http://seo.hitechinfosoft.com

  14. edwina
    said on May 29, 2006 at 8:31 am

    thank you for your work

  15. blayne
    said on May 30, 2006 at 2:08 pm

    I’m love this great website. Many thanks guy

  16. Esteban Panzera
    said on July 3, 2006 at 11:09 pm

    thanks, I have just put this inmy blog :)

  17. Klaas Koopman
    said on July 8, 2006 at 4:31 pm

    Hey what exactly do the permalink lines look like?

  18. Jim Westergren
    said on July 8, 2006 at 5:18 pm

    Hi Klaas,

    like the ones on your new blog.

  19. Klaas Koopman
    said on July 8, 2006 at 6:21 pm

    I mean about this text:

    Add the following lines in the .htaccess file before the WordPress permalinks lines:

  20. Jim Westergren
    said on July 8, 2006 at 6:40 pm

    Oh, ok. You need to download your .htaccess file and you will see. It is 20 lines or something at the end of the file.

  21. Klaas Koopman
    said on July 8, 2006 at 7:00 pm

    could you give me an example of how the lines look like? cause I see lines, but not sure which is the right one and where it should be!

  22. Jim Westergren
    said on July 8, 2006 at 7:07 pm

    You don’t need to insert any lines as it was done automatically when you enabled the permalinks. They start with this: “# BEGIN WordPress”.

  23. Klaas Koopman
    said on July 8, 2006 at 8:26 pm

    So I have to add this Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^myblog\.com
    RewriteRule ^(.*)$ http://www.myblog.com/$1 [R=permanent,L]

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://www.myblog.com/$1/ [L,R=301]

    before the BEGIN Wordpress part?

  24. Jim Westergren
    said on July 9, 2006 at 1:21 am

    Yes. But replace myblog.com with the domain name of your blog.

  25. thai-ebook
    said on July 11, 2006 at 4:23 pm

    I ‘ll tri it with my blog http://www.thai-ebook.com

  26. Marios
    said on July 25, 2006 at 7:51 pm

    Jim,

    Any thoughts on whether it makes sense to use URLs of this format

    http://www.myblog.com/index.php/my-blog-post

    instead of

    http://www.myblog.com/?p=123

    I ask because I’ve got a WordPress blog on Microsoft’s IIS which doesn’t support rewrites without a special plug-in that my host won’t install. I’d like to do what’s best from an SEO perspective, but the variation with index.php looks messy.

  27. Jim Westergren
    said on July 25, 2006 at 11:38 pm

    “http://www.myblog.com/index.php/my-blog-post” would be better as you then get the KWs in the URL but it is not a critical point, you decide.

  28. Ambatchdotcom Seocontest
    said on August 17, 2006 at 1:34 pm

    Dont you think filename.html would help more?

  29. Tom
    said on September 25, 2006 at 8:28 pm

    Is this considered a 301 or 302 redirect?

  30. Jim Westergren
    said on September 25, 2006 at 8:31 pm

    Is this considered a 301 or 302 redirect?

    301 of course! :)

  31. Christer Edwards
    said on November 21, 2006 at 6:04 pm

    I noticed that code caused errors on my server. I’m not sure what is configured differently but I had to use the following:

    Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond ${HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^christeredwards\.com
    RewriteRule (.*) http://christeredwards.com/$1 [L,R=301]

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule (.*) http://christeredwards.com/$1/ [L,R=301]

    This redirects to http://domain.com/some-folder/ (instead of the example above that includes the www.

  32. Christer Edwards
    said on November 30, 2006 at 11:31 pm

    Jim I’m curious on your feelings about the difference in using the www vs non-www domain addresses. I recently wrote a quick post about it and I’d love some more feedback on the issue. It seems to be somewhat controversial from some of the feedback I’ve got so far. Your thoughts?

    http://christeredwards.com/proper-method-of-linking-www-non-www/

  33. Jim Westergren
    said on December 2, 2006 at 4:36 pm

    Hi Christer,

    Jim I’m curious on your feelings about the difference in using the www vs non-www domain addresses.

    The www-version is slightly better. WHY?

    It is the most common version and when you get natural links from people on the top of their head (no cut and paste of URLs) they tend to link to the www-version.

    But if you started with one version – stick to it.

    In some cases such as digg.com and other web 2.0 sites it would be better without www as you have a short domain and when you are that big people will learn and know which version you are using.

    In 5 years from now it might be the other way around – I don’t know.

    Just my 2 cents.

  34. Software Driver Download
    said on February 8, 2007 at 6:46 pm

    Thanks! I tried your trick on my site http://www.softwaredriverdownload.com and now it is working perfectly diverting all non-www to url with www

    Thanks and keep up the good work!

  35. Michael
    said on February 20, 2007 at 6:37 pm

    I think the way I set this up with my host automatically does the conversion, just in reverse. All http://www.netexperienced.com traffic switches to read http://netexperienced.com…you say stick with this, so I will, but am I missing out on link juice from people who link to me by http://www.netexperienced.com? I wasn’t totally clear. Thanks!

    Mike

  36. John Apache
    said on March 15, 2007 at 5:15 am

    Nice post Jim.. I just read a complementary article on askapache about using robots.txt to control google.

    http://www.askapache.com/2007/seo/seo-with-robotstxt.html

  37. Jim Westergren
    said on March 15, 2007 at 3:23 pm

    Thanks John and very nice site you have. I have bookmarked it for later study/reference.

  38. webee
    said on March 22, 2007 at 9:18 am

    replace myblog.com with the domain name of your blog

    .

    hi,

    i have my blog on http://www.webee.ro/webeeblog. and i have set a permanent redirect:
    from www[.]root domain[.] ro to www[.]rootdomain[.]ro/webeeblog

    should i replace myblog.com with the root domain, or with the www[.]rootdomain[.]ro/webeeblog?

    thanks for help,
    webee.

  39. Eddie Walter
    said on March 22, 2007 at 10:00 pm

    Hey Jim,

    This is great info, but I’ve been having a problem when I find great tips like this for WordPress blogs. They are all written as if you are hosting on an Apache server.

    There’s where my problem lies. I host my blog on an IIS server. Any idea how to do this with an IIS server since it doesn’t use a .htaccess file?

    The other thing I’m trying to figure out is how to change my permalinks to NOT include /index.php/%post name%/. I just want /%post name%/. But the workaround I’ve found for this also includes instructions with a .htaccess.

    Any help would be appreciated! You’ll definitely get a link back to your site WITHOUT a nofollow. =)

  40. Sheena
    said on March 24, 2007 at 2:02 pm

    I tried this but when I try to login to my wordpress admin, it redirects to a 404. Any ideas?

    Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^sophistishe\.org
    RewriteRule ^(.*)$ http://www.sophistishe.org/$1 [R=permanent,L]

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://www.sophistishe.org/$1/ [L,R=301]

  41. Jim Westergren
    said on March 24, 2007 at 9:08 pm

    webee,

    As I see it you have the blog in the root of the domain?

    Eddie,

    Well, what about moving to an Apache server? I don’t know the answers to your questions and I am not even sure if it is possible.

    Sheena,

    Did you keep the lines that was placed there by WordPress for the permalinks?

  42. KJ
    said on March 25, 2007 at 5:13 am

    Thanks so much for making this accessible. I’ve been looking all over for this redirect to avoid the canonicalization issue.

    I’m in SEO myself, but fairly new to the blogger scene. So this is great stuff.

  43. Sheena
    said on March 26, 2007 at 4:58 am

    I sure did. The code:

    Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^sophistishe\.org
    RewriteRule ^(.*)$ http://www.sophistishe.org/$1 [R=permanent,L]

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://www.sophistishe.org/$1/ [L,R=301]

    # BEGIN WordPress

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

    # END WordPress

  44. Billy
    said on March 26, 2007 at 7:00 pm

    What’s the right code if the blog is into a subdir? (For example: http://www.mywebsite.com/blog/).
    Thanks!

  45. Randy Gibbons
    said on March 30, 2007 at 2:31 pm

    Excellent Aricle my Friend
    Could you send me the html code that this would look like on a blog. I understand what you have said but still not to sure where or how you put it in.
    I am lacking some of the understanding. Can this nofollow ad in be done in text rather than html?
    Tremendous article, you found somthing that many of us did not know and thanks again.

    Randy Gibbons

  46. Zorus
    said on April 1, 2007 at 2:48 am

    this is the tips that all wordpress user should know

  47. Sheena
    said on April 2, 2007 at 9:45 am

    I set my perma links to look like this: http://myblog.com/my-blog-post and in my htaccesss wordpress inserted:
    # BEGIN WordPress

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

    # END WordPress

    To use your trick do I keep the code that wordpress gave me or delte it and insert what you’ve posted. I think I’m getting an error because I pasted the code that you provided on top of what wordpress provided to it looks like this:
    Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^sophistishe\.org
    RewriteRule ^(.*)$ http://www.sophistishe.org/$1 [R=permanent,L]

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://www.sophistishe.org/$1/ [L,R=301]

    # BEGIN WordPress

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

    # END WordPress

  48. Sheena
    said on April 2, 2007 at 10:04 am

    Turns out I had to use Christer Edwards’ code. It works fine now!

  49. chris
    said on April 5, 2007 at 11:42 pm

    Sheena – what code are you using now for your .htaccess I’m a simliar issue. My post names are not working correctly and I assume it’s .htaccess related.

  50. kiviniar
    said on April 18, 2007 at 11:44 pm

    Thanks a million, it worked and hope to see my pages back from the supplemental results in google

  51. Jenny
    said on April 21, 2007 at 5:29 am

    Nifty. Thanks for the info.

  52. Tommaso
    said on May 3, 2007 at 9:12 pm

    Hi, I would like to know how to set the code if the blog is into a subdirectory like http://www.mysite.com/myblog/.
    What should I change?
    Thanks in advance.

  53. vino
    said on May 15, 2007 at 3:43 am

    Thanks for the tip, I use it on my blog and it works great, thanks. I have similar question with Tommaso, I’d like to know how to write it on a sub domain blog, http://blog.domain.com
    I have several blogs on free hosting with that URL. :)
    Thanks again.

  54. greenisle
    said on May 24, 2007 at 12:54 pm

    Hi all,
    My blog is in a subfolder not on the root domain as the above examples so I am also wondering how to modify this code slightly to work for the extra /blog/ subfolder – could anyone explain?

    I’ve tried a few variations of the above codes adding /blog/ onto the root domain but it gives internal errors. My perma links are set as: http://www.myblog.com/blog/my-blog-post

    Hoping for some direction… thank you,

  55. Andreas Bard
    said on May 28, 2007 at 11:51 am

    I also get errors and my blog is under /blog/. Any suggestions?

    //Andreas

  56. kristin
    said on June 1, 2007 at 9:16 pm

    Great post. Thanks! But Help–
    I changed the file as suggested, but now my photos don’t work. Should I just reload them, or is this a sign of something wrong? It’s at http://www.holisticmaine.com
    Thanks!!

  57. CuXe
    said on June 17, 2007 at 4:27 am

    **************** TIP *********************

    Hi guys I just logged in to say that after changing the .htaccess from the non-www version to the www version I started to have a series of problems editing posts, deleting or adding categories, etc. (I’m using WP v2.2)

    After 48 hours of intense editing and customization I realized there was a problem and the thought of doing everything again .. made me wanna puke …

    ***The problem:

    When you try to add a category the “add category” button does nothing and the information entered dissapears.
    Trying to add a category from a post shows the same problems.

    ***Solution:

    Grab a beer and Chillax!…then read the following explanation:

    The problem seems to be caused by the .htaccess modification in order to push the .www version of your blog.

    Simply go to OPTIONS>>>GENERAL and change your wordpress and blog address (URL) to the www version.

  58. Josh Spaulding
    said on June 23, 2007 at 3:51 am

    I’m having the same issue, as my blog is in a subdirectory mysite/blog

    mysite.com/blog/ works fine but I get an error when trying to load mysite.com/blog

    Any suggestions?

  59. Karla
    said on June 26, 2007 at 5:54 am

    Gracias!

  60. JohnBoy
    said on July 1, 2007 at 6:06 pm

    Hi Jim,
    My site doesn’t use the http://www.myblog.com/my-blog-post/ style links, it uses http://www.myblog.com/2007/06/18/my-blog-post/. You mentioned somewhere else that if it wasn’t a new site DON’T change this. Does this mean that I can’t place this code before the links code in the .htaccess file? I’m really worried about breaking my site but also worried about messing up Google chances!

    Lovely blog – thanks.

  61. Matt Ellsworth
    said on July 3, 2007 at 6:31 pm

    I can’t get this to work on my site that is hosted in a sub directory – everything works except if you go to articlesnatch.com/blog it doens’t redirect correctly. SO i have removed the lines but here is what i had.

    without the comment ## of course

    #Options +Indexes
    #Options +FollowSymLinks
    #RewriteEngine on
    #RewriteCond %{HTTP_HOST} ^articlesnatch\.com
    #RewriteRule ^(.*)$ http://www.articlesnatch.com/blog/$1 [R=permanent,L]

    #RewriteBase /
    #RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteCond %{REQUEST_URI} !(.*)/$
    #RewriteRule ^(.*)$ http://www.articlesnatch.com/blog/$1/ [L,R=301]

  62. John Sylvester
    said on July 6, 2007 at 1:33 pm

    WordPress is far superior. You can add it as a seamless addition to your pages. Ideal for smaller sites wanting more content. Blogger is a waste of time, in my opinion – there are no RSS feeds so no directory listings, which is one of the points of adding content in this way and diversifying keyword space.

  63. Dave Laxton
    said on July 17, 2007 at 12:53 am

    What are the lines to add for a subdomain?
    You are a HUGE asset to me and I appreciate all you do.
    Thanks,
    Dave

  64. zooloo supra
    said on October 5, 2007 at 12:29 am

    great information Jim, i will check this at my wordpress 2.2 blog

    zooloo

  65. Photoshop user
    said on October 14, 2007 at 11:25 am

    Sweet! Its not enough to just format this in the permalinks setting to custom /blogpost/?

    Great site JIm!

  66. Traian
    said on October 18, 2007 at 6:44 am

    the redirect only works if you have the blog it self as the domain name. if you host the blog like http://www.corporateside.com/blog and you are redirecting the non www of the root site to the www version the blog redirect won’t work

  67. Szucs Laszlo
    said on November 11, 2007 at 1:50 am

    Hmm I am actually use a WordPress Blog. But have no idea of this issue. Thanks for the post.

    Cheers,

  68. pipholicdotcom
    said on December 3, 2007 at 12:06 am

    hi jim, I set my permalink structure for the post to this : %postname%.html I think it is much easier than editing htaccess file. I dont think anybody will link to my post using an ending slash if they see the html extention at the end of the link.

    However, I dont know how it will go with my page or category link.

  69. marcuzzer
    said on December 7, 2007 at 8:48 pm

    It seems there’s an unanswered question here. I do have the same problem:
    domain.com/blog/
    and posts that include the date like
    domain.com/blog/index.php/12/12/07/title-of-post

    Now I would like to thank for the useful article, but if anybody can solve out this problem i would be happier.

    Onre more thing: my .htaccess file is very long. Where should i place the code? exactly here?

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ – [S=35]
    RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?&feed=$1 [QSA,L]
    RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?&feed=$1 [QSA,L]
    RewriteRule ^page/?([0-9]{1,})/?$ /blog/index.php?&paged=$1 [QSA,L]
    RewriteRule ^comments/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?&feed=$1&withcomments=1 [QSA,L]
    RewriteRule ^comments/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?&feed=$1&withcomments=1 [QSA,L]
    RewriteRule ^comments/page/?([0-9]{1,})/?$ /blog/index.php?&paged=$1 [QSA,L]
    RewriteRule ^search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?s=$1&feed=$2 [QSA,L]
    RewriteRule ^search/(.+)/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?s=$1&feed=$2 [QSA,L]
    RewriteRule ^search/(.+)/page/?([0-9]{1,})/?$ /blog/index.php?s=$1&paged=$2 [QSA,L]
    RewriteRule ^search/(.+)/?$ /blog/index.php?s=$1 [QSA,L]
    RewriteRule ^category/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?category_name=$1&feed=$2 [QSA,L]
    RewriteRule ^category/(.+)/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?category_name=$1&feed=$2 [QSA,L]
    RewriteRule ^category/(.+)/page/?([0-9]{1,})/?$ /blog/index.php?category_name=$1&paged=$2 [QSA,L]
    RewriteRule ^category/(.+)/?$ /blog/index.php?category_name=$1 [QSA,L]
    RewriteRule ^author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?author_name=$1&feed=$2 [QSA,L]
    RewriteRule ^author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?author_name=$1&feed=$2 [QSA,L]
    RewriteRule ^author/([^/]+)/page/?([0-9]{1,})/?$ /blog/index.php?author_name=$1&paged=$2 [QSA,L]
    RewriteRule ^author/([^/]+)/?$ /blog/index.php?author_name=$1 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&monthnum=$2&d
    ay=$3&feed=$4 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&monthnum=$2&day=$3
    &feed=$4 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /blog/index.php?year=$1&monthnum=$2&day=$3&paged=
    $4 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /blog/index.php?year=$1&monthnum=$2&day=$3 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&monthnum=$2&feed=$3 [QSA,L
    ]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&monthnum=$2&feed=$3 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /blog/index.php?year=$1&monthnum=$2&paged=$3 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/?$ /blog/index.php?year=$1&monthnum=$2 [QSA,L]
    RewriteRule ^([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&feed=$2 [QSA,L]
    RewriteRule ^([0-9]{4})/page/?([0-9]{1,})/?$ /blog/index.php?year=$1&paged=$2 [QSA,L]
    RewriteRule ^([0-9]{4})/?$ /blog/index.php?year=$1 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$ /blog/index.php?year=$1&monthnum=$2&day=$3&name=$
    4&tb=1 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&month
    num=$2&day=$3&name=$4&feed=$5 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&monthnum=$
    2&day=$3&name=$4&feed=$5 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/page/?([0-9]{1,})/?$ /blog/index.php?year=$1&monthnum=$2&day=$
    3&name=$4&paged=$5 [QSA,L]
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$ /blog/index.php?year=$1&monthnum=$2&day=$3&name=$
    4&page=$5 [QSA,L]

    # END WordPress

  70. Eddie
    said on February 27, 2008 at 2:03 pm

    hello…i have de htaccess set up for: http://www.name.com/post-name
    now i copy the code above…but i have this error:

    The page isn’t redirecting properly

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    my htaccess file looks like:

    Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^cazutdincer\.com
    RewriteRule ^(.*)$ http://www.cazutdincer.com/$1 [R=permanent,L]

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://www.cazutdincer.com/$1/ [L,R=301]

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

    what i do wrong pls help me!!!

  71. Forex Trading Ace
    said on April 7, 2008 at 5:13 pm

    This is for wordpress…What about if i use blogger Jim?

  72. Nicholas
    said on July 28, 2008 at 5:55 pm

    Thank you for your advices.

    Nicholas

  73. Paline
    said on January 17, 2009 at 1:01 am

    Hi, Could you please tell me where I would insert the above code. I have put it into my (single post.php) above this line;
    <h1 id=”post-”><a href=”" rel=”bookmark” title=”Permanent Link: “>
    Can you please tell me if this is correct. I am not sure I am following you regarding .htaccess is this the same thing as what I have done.

  74. Paline
    said on January 17, 2009 at 1:05 am

    Hi Joe,
    No that did not work, the code showed up above my post heading.
    Any ideas???

  75. jswa
    said on January 28, 2009 at 8:16 pm

    Hi, I can’t seem to find this solution anywhere and can’t seem to code it myself…

    I’m trying to redirect all http://www.domain.com to subdomain http://sub.domain.com

    does anyone know how I can do that?

    Thank you!

  76. Jim Westergren
    said on January 28, 2009 at 10:53 pm

    @jswa, Try this:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.com
    RewriteCond %{REQUEST_URI} -d
    RewriteRule .* http://sub.domain.com%{REQUEST_URI} [L,R=301]

    Source:
    http://act.ualise.com/blogs/continuous-innovation/2008/11/apache-domain-to-subdomain-redirection/

  77. Lea
    said on March 10, 2009 at 6:16 pm

    Thanks for providing the code with this information. Very helpful.

  78. Alex
    said on March 17, 2009 at 12:15 am

    Thanks Jim.

    I have little question. I have ‘RewriteEngine on’ defined in .htaccess before code you provided. Can this line be eliminated, or I must keep it twice?

  79. Jim Westergren
    said on March 17, 2009 at 2:10 am

    @Alex,

    Just once is good enough.

  80. Jason
    said on April 15, 2009 at 11:11 pm

    Is there a way to test this to make sure it’s doing what it’s supposed to do?

  81. wayan
    said on April 24, 2009 at 2:13 pm

    I was change my .htaccess to

    Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^wayan\.web.id
    RewriteRule ^(.*)$ http://www.wayan.web.id/$1 [R=permanent,L]

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://www.wayan.web.id/$1/ [L,R=301]

    # BEGIN WordPress

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

    # END WordPress

    But my server says there is some misconfiguration. can you give a solution for my domian??

  82. Jim Westergren
    said on April 27, 2009 at 4:30 pm

    Hi wayan,

    It is hard to say when I don’t have more information. But try deleting line number 4 and 5 and see if it works.

  83. Susan
    said on May 17, 2009 at 8:44 am

    Hi Jim,

    Excellent post.

    How do I know if it is working fine as without editing my current .htaccess file, all my articles automatically link to http://www.mydomain.com/articles/. Should I need to modify according to your codes? My current .htaccess as below.

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

  84. Adam
    said on September 24, 2009 at 1:47 pm

    … so when I put my URL at the bottom of my signature when commenting on other people’s blogs, twitter, etc, should I keep the slash on the end of the URL as http://www.mydomain.com/ ? (since my domain will now have the slash at the end of the URL)

  85. Gareth James
    said on September 30, 2009 at 10:30 am

    @Adam – You should always use / at the of your domain name when link building. The non / is usually 301 redirected to the / version, but you will get link juice leakage.

    Jim, I’m new to Wordpress SEO – Is this all still needed in 2009? If yes do you need to add it for every new page created or can 1 bit of code sort everything (and future posts)?

  86. Jim Westergren
    said on October 1, 2009 at 11:40 am

    Hi Gereth,

    No, this is not anymore needed. It is taken care of in the new version of Wordpress. I have updated the article and thanks for heads up.

  87. Midhun Devasia
    said on November 29, 2009 at 8:06 pm

    Hi Jim,
    In my blog I append one .html after the postname.
    like http://tutorboy.com/articles/linux/creating-a-playlist-for-mplayer.html

    http://tutorboy.com/articles/ is the blog section.
    linux is the category name.

    is this affect my SEO :( , I have some other business related to the the domain so i cant put wordpress in my root, that is why i made a section as articles for wordpress. What do you think is this optimized?

  88. Nick
    said on January 28, 2010 at 1:00 am

    Jim this is what my htaccess file looks like. Is this ok?

    # BEGIN WordPress

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

    # END WordPress

    RewriteCond %{HTTP_HOST} ^mywebsite.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.mywebsite.com$
    RewriteRule ^/?$ “http\:\/\/www\.mywebsite\.com” [R=301,L]

  89. Recent Inside
    said on February 1, 2010 at 11:15 am

    Nice Article. After searching Wordpress SEO I landed on your page. I am 100% impressed

  90. oblio
    said on February 4, 2010 at 12:14 pm

    is it posiblle that my host does this already through another mechanism? i have noticed that it automaticly redirects to http://mydomain.com/. i don’t have the lines you mentioned in my htaccess file.

  91. kumaran
    said on February 11, 2010 at 6:10 am

    if you are using the latest version of wordpress guys then ignore this article. not needed anymore. :)

Leave a Comment

To quote: <blockquote>text to quote</blockquote>

You can use these tags: <a href=""> <blockquote> <code> <em> <strong>


To have a photo of you beside your comments, upload a photo here.

Pingbacks
  1. [...] Handling duplicate content Part of a SEOs job is removing duplicate content on a site. Any content that shows up same for more than 1 URL should be fixed. This includes the non-www redirect. Example with default WordPress. [...]

    Pingback by SEO Professional? SEO subjects you need to know — October 28, 2006 @ 7:24 am

  2. [...] För dig som använder Wordpress som bloggprogramvara är mycket av den grundläggande sökmotoroptimeringen redan gjord. Du kan däremot gÃ¥ igenom följande för att optimera din blogg riktigt bra: Kontrollera det tema du använder pÃ¥ bloggen: Kommer det viktigaste innehÃ¥llet högst upp och används rubriktaggarna pÃ¥ rätt sätt? Läs Jim Westergrens utmärkta guider: “SEO for Wordpress blogs” samt “WordPress users – sharpen your URLs with Google!“. [...]

    Pingback by Sökmotoroptimering för Wordpress — March 8, 2007 @ 5:27 pm

  3. [...] Every WordPress has an issue in which there are 4 different URLs for the same post and this has to be fixed. Follow my guide on how to fix it here. [...]

    Pingback by Success with SEO for WordPress — March 17, 2007 @ 4:53 am

  4. [...] WWW Redirect Sharpen your urls by controlling how users access your blog posts. Jim’s post on canonicalization is a “must read” with  a better explanation on redirects and why you should be using them. [...]

    Pingback by SEO Plugins for Wordpress 2007 — March 21, 2007 @ 9:16 pm

  5. [...] http://www.jimwestergren.com/wordpress-users-sharpen-your-urls-with-google/ [...]

    Pingback by Thoreplass.Net “IT-Blogg” » Blog Archive » WordPress users - sharpen your URLs with Google! — March 27, 2007 @ 3:23 pm

  6. [...] I use WordPress as a CMS for my personal site as well as for several sites I have done for clients. One of the things I like about WordPress is the ease with which permalinks can be changed. However, as Jim Westergren points out, WordPress ends up with 4 different URLs to the same post: one with the www, one without, one with the trailing slash, and one without. This isn’t a good thing from an SEO perspective because Google will treat these URLs as just that: 4 different URLs. On that scheme, you’ve got 4 URLs with 4 different values. Don’t worry too much though, because there is an easy way to bring them and their combined weight together by editing your .htaccess file. [...]

    Pingback by SEO Friendly URLs in WordPress | Simon Shull-Foust — March 28, 2007 @ 7:57 am

  7. [...] Every WordPress blog has an issue in which there are 4 different URLs for the same post and this has to be fixed to prevent dilution. Follow my guide on how to fix it here. [...]

    Pingback by SEO for WordPress - The Complete Guide - Business Online Blog — March 31, 2007 @ 9:48 pm

  8. [...] Fuente: Jim Westergren. [...]

    Pingback by Wordpress: evita el contenido duplicado en Google « Liamngls — April 2, 2007 @ 5:45 am

  9. [...] En todo blog de WordPress hay 4 formas diferentes de establecer la URL de cada artículo y se debe establecer una de ellas para evitar contenido duplicado. En este enlace (inglés) encontrará como hacerlo. [...]

    Pingback by Caminante » SEO para WordPress — April 8, 2007 @ 10:25 pm

  10. [...] Use the same linking structure throughout your site! Did you know that in google’s eyes the following are ALL DIFFERENT pages http://www.domain.com/article http://www.domain.com/article/ domain.com/article domain.com/article/ Yep, that’s right google will see that single page of content as FOUR seperate pages! Now add the category page, home page, and archive page and you can understand why the MORE tag is so important. Talk about major duplicate content! If you did nothing about this problem google would pick and choose which article to rank better and it probably isn’t the one you watnt. Luckily we went over the www. problem in #2 above, but what about the rest? How do you fix http://www.domain.com/article and /article/? SIMPLE, you have the power in your hands! When you link to your other blog posts ALWAYS link the same way your permalink structure is setup (more on this later). If you use /article link /article if you use /article/ link /araticle/ it’s THAT SIMPLE! This is true for when you setup related posts, most recent posts, and NOT only wheny ou link to another post from within a post. Whever you link to your posts from use the same link as your blog is using automatically!If you want to take this one step further and FORCE everyone to use the same link structure Jim has a great tutorial on how to setup .htaccess for re-directing wordpress articles. Be sure to read his entire post and comments before attempting the process mentioned because there have been recent additions to his post. [...]

    Pingback by Ultimate Wordpress SEO Guide — May 11, 2007 @ 3:57 am

  11. [...] 规范化URL 每个基于WordPress的博客都有一个问题:同一篇文章存在4个不同的URL。这个问题一定要修复以阻止链接稀释化。可以参考我的方法来规范化URL。 [...]

    Pingback by WordPressçš„SEO技巧完全指南 at catch the digital flow — July 30, 2007 @ 9:52 am

  12. [...] Every WordPress blog has an issue in which there are 4 different URLs for the same post and this has to be fixed to prevent dilution. Follow my guide on how to fix it here. [...]

    Pingback by MrHoang Blog » SEO for WordPress - The Complete Guide — August 15, 2007 @ 12:26 pm

  13. [...] Jim Westergreen explains the rest in his “Sharpen your URL’s with Google” post. Unfortunately, his guidance only works if your blog is hosted on a top level domain (TLD). In other words, his post will set you straight if your blog is at yoursite.com but if it’s in a subdirectory, as mine is, like yoursite.com/blog/ then it’s not going to work for you. This will have to be solved through some advanced .htaccess work, which I’m not fluent with. So, if you notice, I haven’t completely solved this issue for myself yet. If you know how, I’d love to know. [...]

    Pingback by WordPress SEO Tips Tricks and Plugins — August 21, 2007 @ 8:04 am

  14. [...] 4 different URLs for the same post ? [...]

    Pingback by Search Engine Friendly Wordpress — November 20, 2007 @ 11:37 pm

  15. [...] You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your ownsite. [...]

    Pingback by Gabfire » Top 4 SEO mistakes of bloggers — November 28, 2007 @ 1:24 pm

  16. [...] Google sees 4 different URLs and 4 different pages while in fact there is only one. This is called as canonicalization problem. For solution of this problem you need to edit your .htaccess file. Check here for a quick fix. [...]

    Pingback by Top 4 SEO mistakes of bloggers — December 21, 2007 @ 3:17 pm

  17. [...] I have borrowed some of the ideas from jimwestergren and modified with a couple of practical points gained both from expierence and experimentation. [...]

    Pingback by Optimizing Content: Empowering your content’s value online, 14 things you thought you knew but never bothered to do. : Adventures in Online Marketing — February 23, 2008 @ 1:56 pm

  18. [...] as canonicalization problem. For solution of this problem you need to edit your .htaccess file. Check here for a quick fix. This entry was posted on Friday, December 21st, 2007 and is filed under [...]

    Pingback by gabfire themes » Blog Archive » Top 4 SEO mistakes of bloggers — April 26, 2008 @ 10:08 pm

  19. [...] end up pointing to one url. Sound complicated?  It’s not really. This article explains the canonicalization problem in more detail. I like the .htaccess file they are promoting there and am using it [...]

    Pingback by Make Cash Online Blog » Blog Archive » Dealing with wordpress canonicalization problem — September 2, 2008 @ 2:36 pm

  20. [...] źródło: jim westergen [...]

    Pingback by .htaccess i linki w Wordpressie — September 26, 2008 @ 1:40 pm

  21. [...] Every WordPress blog has an issue in which there are 4 different URLs for the same post and this has to be fixed to prevent dilution. Follow my guide on how to fix it here. [...]

    Pingback by SEO Tips for WordPress - The Complete Guide | Wordpress Expert — October 3, 2008 @ 7:13 am

  22. [...] website.com doesn’t automatically forward to your http://www.website.com you might want to ‘sharpen your URL’s‘ — making non www. URL’s forward to www. URL’s. Why? Purely for SEO reasons [...]

    Pingback by My WordPress Post-installation Check List | StyleWired — October 19, 2008 @ 12:08 am

  23. [...] WordPress users – sharpen your URLs with Google! canonicalization problem: [...]

    Pingback by technoklutz.com » Blog Archive » Not sure what canonicalization is? — December 16, 2008 @ 9:33 pm

  24. [...] WordPress users – sharpen your URLs with Google! [...]

    Pingback by Hacks to boost your WordPress 2.7 blog — January 12, 2009 @ 8:41 pm

  25. [...] Every WordPress blog has an issue in which there are 4 different URLs for the same post and this has to be fixed to prevent dilution. Follow my guide on how to fix it here. [...]

    Pingback by SEO for WordPress – The Complete Guide « Social Media Greece — February 15, 2010 @ 11:34 pm

Previous post in category: V7ndotcom Elursrebmem

Next post in category: Lady Google

Design by myself:  valid XHTML and valid CSS.