Page 1 of 1

how to add prefix www to URL permanently [solved]

Posted: Thu Aug 25, 2011 7:40 pm
by coolji
Hi all,

I just installed the module GoogleSitemap on my client site. zenclimb.com. I tried to submit sitemap link http://zenclimb.com/sitemap.xml to Google, but Google would not accept URL without the prefix www. So I added prefix www in config.php. It works if just type zenclimb.com, it will redirect to http://www.zenclimb.com. However, if I add the sub pages, http://zenclimb.com/programs.html, it will not add prefix www. The problem is Google still not recognize my sitemap URL.

Do you know if there is any ways to add prefix www permanently?

Thanks in advance!

Jason

Re: how to add prefix www to URL permanently

Posted: Thu Aug 25, 2011 8:14 pm
by coolji
I found a solution to add prefix www.

RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=permanent,L]

Howerver, Google still not reconize this change. Here is the error message from Google.
Paths don't match
We've detected that you submitted your Sitemap using a URL path that includes the www prefix (for instance, http://www.example.com/sitemap.xml). However, the URLs listed inside your Sitemap don't use the www prefix (for instance, http://example.com/myfile.htm).
Do you have any solutions?

Thanks,

Jason

Re: how to add prefix www to URL permanently

Posted: Fri Aug 26, 2011 9:01 am
by uniqu3
How does your config.php $config['root_url'] look like?
I bet there is www. missing that is why your sitemap is created without www.

Re: how to add prefix www to URL permanently

Posted: Fri Aug 26, 2011 8:17 pm
by coolji
Yes, there was www. missing in the config.php. It has been added.

But I still need to add the following in .htaccess to make it fully work.

RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=permanent,L]


Now Google has accepted my sitemap. I guess when I added URL redirect in .htacccess, it took a while to update in Google. Now everything works fine.

Re: how to add prefix www to URL permanently

Posted: Sun Aug 28, 2011 11:38 am
by M@rtijn
So this question is resolved?

Maybe could you edit the first post so it shows [solved] in the title?
Thank you!