Hi, I want to know how i can remove www. from a www.sitename.com And get the msn search to index only sitename.com not www.sitename.com
try this: In the .htaccess-file: RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.site\.com$ RewriteRule ^(.*)$ http://site.com/$1 [L,R=301] ("site" should be your site of course)
at http://5nz.com I use XBitHack Off RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.5nz\.com [NC] RewriteRule ^(.*)$ http://5nz.com/$1 [L,R=301] Code (markup):
Or here's a plain php code you can use : <?php if(stristr($_SERVER["HTTP_HOST"], 'www')){ header("HTTP/1.1 301 Moved Permanently"); header("Location: http://non-www-url" . $_SERVER["REQUEST_URI"]); exit(); } ?> Code (markup):
I have write it to .htaccess want to know one thing more. After writing this to .htaccess does this also changes the url in internet explorer. When i type www.sitename.com will this automatic change to http://sitename.com in internet explorer after writing this to .htacess? Cause it does not change, but i dont need to change it. Just want to index the site without www. to search engine. Thanks
If it is not changing in your browser's address window, it is not working correctly. With a 301 redirect, you should see the address change. Not all hosting companies allow you to do server overrides with the .htaccess file, and it will only work on a Linux or Unix server running Apache.
Put this code in the .htaccess file under root ( public_html ) Subsitute domain and .com with your values... ## Custom direct all to http RewriteEngine On RewriteCond %{HTTP_HOST} ^www.domain\.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L] Code (markup):
I put this code in .htaccess and it worked. It changed the url to http://sitename.com but the problem is it does not load the site. It stop after changing the url in internet explorer. A little bit of more code, thanks.
Sorry for the intrusion tigersoft, but I would like to know what to do getting the inverse results, site going to www instead. My site is best ranked with the www, so just wandering
RewriteEngine on RewriteCond %{HTTP_HOST} ^yourdomain\.com RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=permanent,L]
I kinda prefer my own sites to retain the "www" instead of without. It seems more people are apt to recognize it (as opposed to links.) on offline advertisements.
Be careful when doing this redirect as search engines see both www and non-www as different sites and if you have a ranking with www version for some keyword, you run the risk of loosing the position. Bye
No, the point of doing this redirection is to make the seach engines see both the www and the non-www as one site. Thus making it stronger by collecting all incoming links to one domain.