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.

Boomark This! Subscribe to the RSS feed
About the Author Jim Westergren Jim Westergren is a web entrepreneur from Sweden now living in Bolivia. He is happily married and has two lovely children. Some of his interests are web development, SEO and writing. He is the Founder and CTO of TodaysWeb and his current major project is N.nu. Read his . Follow Jim on Twitter or Google+.
  • http://www.marcuswestberg.com/ Marcus

    Great post Jim!
    I used it! :)

  • http://www.hairclinic.blogspot.com/ mazhar

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

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    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 :)

  • http://ppc-directory.com Russell

    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?

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    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 :)

  • http://cams.911cams.com Nata

    Excellent article !

  • http://verizon-wireless-ringtones.onlybest.info Max

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

  • http://unsecured-personal-loans-foryou.blogspot.com Maxell

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

  • http://handbags.irishost.net Timberlend

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

  • http://www.betalover.com/ Dave

    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?

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    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.

  • http://www.secret-casino-files.com Socrat888

    Thank’s Great post

  • http://seo2india.freelancebank.com Devang Barot

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

  • http://www.geocities.com/toner13tonerxerox/brother-toner/ edwina

    thank you for your work

  • http://pill4orderxanax.tripod.com/zocor/ blayne

    I’m love this great website. Many thanks guy

  • http://www.estebanpanzera.com Esteban Panzera

    thanks, I have just put this inmy blog :)

  • http://www.koopmansblog.com Klaas Koopman

    Hey what exactly do the permalink lines look like?

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    Hi Klaas,

    like the ones on your new blog.

  • http://www.KoopmansBlog.com Klaas Koopman

    I mean about this text:

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

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    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.

  • http://www.KoopmansBlog.com Klaas Koopman

    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!

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

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

  • http://www.KoopmansBlog.com Klaas Koopman

    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?

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

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

  • http://www.thai-ebook.com thai-ebook

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

  • http://www.mariosalexandrou.com/blog/index.asp Marios

    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.

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

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

  • http://www.ambatchdotcomseocontest.us Ambatchdotcom Seocontest

    Dont you think filename.html would help more?

  • Tom

    Is this considered a 301 or 302 redirect?

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    Is this considered a 301 or 302 redirect?

    301 of course! :)

  • Pingback: SEO Professional? SEO subjects you need to know

  • http://christeredwards.com Christer Edwards

    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.

  • http://christeredwards.com Christer Edwards

    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/

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    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.

  • http://www.softwaredriverdownload.com Software Driver Download

    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!

  • http://www.netexperienced.com Michael

    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

  • Pingback: Sökmotoroptimering för Wordpress

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

    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

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

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

  • Pingback: Success with SEO for WordPress

  • Pingback: SEO Plugins for Wordpress 2007

  • http://www.webee.ro webee

    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.

  • http://www.eddiewalter.com/blog/ Eddie Walter

    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. =)

  • http://sophistishe.org Sheena

    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]

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    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?

  • http://www.chicagocubs-baseball.com KJ

    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.

  • http://sophistishe.org Sheena

    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

  • Billy

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

  • Pingback: Thoreplass.Net “IT-Blogg” » Blog Archive » WordPress users - sharpen your URLs with Google!

  • Pingback: SEO Friendly URLs in WordPress | Simon Shull-Foust

  • http://www.mymarketresources.com Randy Gibbons

    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

  • Pingback: SEO for WordPress - The Complete Guide - Business Online Blog

  • http://dragonstrength.blogspot.com Zorus

    this is the tips that all wordpress user should know

  • Pingback: Wordpress: evita el contenido duplicado en Google « Liamngls

  • http://sophistishe.org Sheena

    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

  • http://sophistishe.org Sheena

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

  • chris

    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.

  • Pingback: Caminante » SEO para WordPress

  • http://www.directorytrials.com kiviniar

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

  • http://pjmommy.com Jenny

    Nifty. Thanks for the info.

  • Tommaso

    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.

  • Pingback: Ultimate Wordpress SEO Guide

  • http://www.jurugan.com vino

    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.

  • greenisle

    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,

  • http://www.andreasbard.com Andreas Bard

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

    //Andreas

  • http://www.holisticmaine.com kristin

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

  • http://www.dparticlesubmission.com CuXe

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

  • http://ez-onlinemoney.com/blog Josh Spaulding

    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?

  • http://www.pequenita.com Karla

    Gracias!

  • JohnBoy

    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.

  • http://www.articlesnatch.com/blog/ Matt Ellsworth

    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]

  • http://www.v9designbuild.com John Sylvester

    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.

  • http://www.davelaxton.com Dave Laxton

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

  • Pingback: WordPressçš„SEO技巧完全指南 at catch the digital flow

  • Pingback: MrHoang Blog » SEO for WordPress - The Complete Guide

  • Pingback: WordPress SEO Tips Tricks and Plugins

  • http://www.zooloo.se zooloo supra

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

    zooloo

  • http://www.photoshop-user.com Photoshop user

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

    Great site JIm!

  • Traian

    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

  • http://www.home-moneybusiness.com Szucs Laszlo

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

    Cheers,

  • Pingback: Search Engine Friendly Wordpress

  • Pingback: Gabfire » Top 4 SEO mistakes of bloggers

  • http://www.pipholic.com pipholicdotcom

    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.

  • http://www.10people.net/blog/ marcuzzer

    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

  • Pingback: Top 4 SEO mistakes of bloggers

  • Pingback: Optimizing Content: Empowering your content’s value online, 14 things you thought you knew but never bothered to do. : Adventures in Online Marketing

  • http://cazutdincer.com Eddie

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

  • http://autopips.blogspot.com Forex Trading Ace

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

  • Pingback: gabfire themes » Blog Archive » Top 4 SEO mistakes of bloggers

  • Nicholas

    Thank you for your advices.

    Nicholas

  • Pingback: Make Cash Online Blog » Blog Archive » Dealing with wordpress canonicalization problem

  • Pingback: .htaccess i linki w Wordpressie

  • Pingback: SEO Tips for WordPress - The Complete Guide | Wordpress Expert

  • Pingback: My WordPress Post-installation Check List | StyleWired

  • Pingback: technoklutz.com » Blog Archive » Not sure what canonicalization is?

  • Pingback: Hacks to boost your WordPress 2.7 blog

  • http://foreverlookingood.com Paline

    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.

  • http://foreverlookingood.com Paline

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

  • jswa

    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!

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    @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/

  • http://www.ourprivatenetwork.com Lea

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

  • http://www.idea2site.com Alex

    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?

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    @Alex,

    Just once is good enough.

  • http://www.constantcraftsman.com Jason

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

  • http://wayan.web.id wayan

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

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    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.

  • http://www.bubblesugar.com Susan

    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]

  • Adam

    … 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)

  • http://www.seo-doctor.co.uk/ Gareth James

    @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)?

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    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.

  • http://tutorboy.com/ Midhun Devasia

    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?

  • Nick

    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]

  • http://www.recentinside.com Recent Inside

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

  • http://iulren.com oblio

    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.

  • http://www.funcargames.org/category/fun-car-games/ kumaran

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

  • Pingback: SEO for WordPress – The Complete Guide « Social Media Greece

  • Pingback: Discover 10 articles that can be really helpful in your SEO work & web dev « my a.m. design

  • Pingback: SEO para wordpress « Seo para wordpress

  • http://beginningspanishlessons.net/ steve

    useful article i’ll use it on my blogs! thanks!

  • http://www.myroadaustralia.com Evangelia Zonnios

    Hi thanks for the great information site. Could you tell me where I can get to the .htaccess file in wordpress to add these lines of text.

  • http://ojxcvqa.com Jackqueline Chatlos

    Liking your site over here, it’s well made lol.

  • http://www.grosirlulurbali.com Lulur Bali

    Great! Thanks for the infos… Now i have huge URLs to ping

Previous post in category:

Next post in category:

Design, text and custom cache solution by myself.

Page generated in
0.00551 sec