Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

When I do a search of my site in Google it shows both:

  • mydomain.com
  • www.mydomain.com

In my .htaccess file I added code to redirect the non-www version to the www version, but both versions are still showing in Google's search results.

Is there anyway to have Google only show the www version?

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

First, I hope you put a proper 301 redirect for any page in your htaccess.

If some of your pages require parameters, like example.com/?p=20, then you need to use mod_rewrite with [R=301] instead of the easier mod_alias Redirect directive in your htaccess. Also, until Google Bot comes again and indexes, it will not update the Google index.

Second, it will take some time for Google to reindex your website. You can try and submit a proper sitemap (sitemap.xml) to google via Google Webmaster Tools but it still might take some time.

Third, you might want to use a rel=canonical tag on your pages - especially if your redirect is not working yet to hint Google for proper indexing of your pages.

share|improve this answer
    
Yep, if you're using 302, then Google likely keeps the old page in the index. Using canonical or 301 will cause the old page to be deindexed and transfer PR to the new url. –  Lèse majesté Oct 29 '10 at 18:34
4  
I addition to submitting a sitemap in your webmaster tools under configuration->settings there is a "preferred domain" option that allows you to choose between the www and non version, that might speed things up a bit as well. –  Joshak Oct 29 '10 at 18:59
    
@Joshak - +1 Thanks, forgot all about that. –  Jeremy Oct 29 '10 at 19:03
add comment

A little bit of an aside, but why do you still want to use the www domain? It's no longer necessary and adds more bloat to your url. Check out the no-www project for more info.

http://no-www.org/

As to your problem, give Google sometime to reindex your site and be happy that your site is still showing up twice in the results.

share|improve this answer
1  
It has been asked before and there are valid reasons to leave the www: webmasters.stackexchange.com/questions/507/… –  Evgeny Oct 31 '10 at 0:42
    
also google showing twice the same result also means that google is giving half the credit for each result. so instead of being on the first page with your single result, you are on the 5th page because of content duplication. –  Evgeny Oct 31 '10 at 0:43
add comment

In addition to Evgeny's very good points, it should be noted that the Google Webmaster's tool allows you to specify a preferred domain, either with or without the www prefixes. Google's explanation of this option follows:

The preferred domain is the one that you would like used to index your site's pages. If you specify your preferred domain as http://www.example.com and we find a link to your site that is formatted as http://example.com , we'll treat that link as if it was http://www.example.com . In addition, we'll take your preference into account when displaying URLs in our search results. It may take some time for changes to be reflected in our index.

You'll find the option under "Site Configurations\Settings".

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.