Hi guys, I have faced a problem. I have hosted a php website on the server and when I sometimes (depend on the browser and computer) try to call 'www.domainname.com' it returns a not found page. It has never happened when I type in with the 'www'. Also, there is someone in charge of the SEO and he is saying that the search robots are finding duplicates URL such as: http://www.domainname.com http://domainname.com http://www.domainname.com/index.php http://domainname.com/index.php so I would like to know how I could better sort it out. I believe I should disable the direct url without the 'www' but I have no idea how to do it if it is by .ht file or how. Thanks in advance
I usually redirect non-www to www...but you can choose..i`ll put some code below which you can use in the .htaccess file Redirect WWW to non-WWW: RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^.*$ http://example.com%{REQUEST_URI} [R=301,L] Redirect Non-WWW to WWW: RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com RewriteRule (.*) http://www.example.com/$1 [R=301,L] I`ve find them on google..just choose whatever you want and replace "example" with your domain
It may be a slow connection. But to sort out the problem with duplicate content, use a 301 redirect, google it and redirect all content to the www. version. This will mean that if you type yourdomain.com it will automatically go to www.yourdomain.com. Search engines are included under this rule so it will not detect duplicate content.
Thank you guys for your replies. Just on more question to joshvelco, how do I exactly do it (use a 301 redirect, google it and redirect all content to the www. version)?
Yes its done with a 301 redirect or mod rewrite on Apache servers http://www.webconfs.com/how-to-redirect-a-webpage.php
This all depends on whether you are running your own server, have dedicated managed hosting, or shared hosting. As far as I'm aware the inclusion of the www. prefix is optional and inconsequential with very few exceptions. Problems like yours are rare (at least to my own knowledge and experience). You could try a redirect as suggested, but I think your best bet (if you have managed hosting) is to call your web hosting service and alert them to this problem, and while you're at it you might want to try calling your domain name registrar because it could be something to do with where and how you parked your domain or your dns name servers.
Did you set nameservers for your domain name or custom records? Make sure to point www to the IP of your webhost if you use custom records.
It's best and preferred to do both. I'd suggest picking up a copy of Oreilly and Associates "DNS and BIND".
I would suggest stick to either version and depending on your domain name decided on wwww or non-www. Some domains make better URLs without the www, such as the INFO domains Here both redirection rules: WITH WWW: RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC] RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L] WITHOUT WWW: RewriteEngine On RewriteCond %{HTTP_HOST} ^www.yourdomain\.com$ [NC] RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L] Code (markup):
Regardless of what might look better or sound better phonetically, people will type it both ways. If they type www and you have no A Record or CNAME/vhost, they will likely think you went poop and go someplace else, and visa versa.
Its really more efficient to simply ad it as an alias both in your zone file and vhost config. No need to ad the redirect. Its just one more step.
I use the non version my self, in Google Webmaster Center i set my preference and you can change it in your .htacces for a 301 redirect.