What does the WWW mean nowadays? It is just the world wide web, synonym for the internet, right?
Then, why should we prefix our websites with www always? It has been a practice for so long to have website domain names start with www. Why don’t we just get rid of it, and have clear and neat simple domains?
Hey, check out http://www.va, the website of Vatican City. .va is the TLD (top level domain) assigned to Vatican City. Does the domain name wwww.va seem to miss the domain name, like www.something.va? 🙂 Nope. Here www is the domain label, and the regular www subdomain is not used. Clear?
For example, in case of www.teck.in, technically the www is nothing but a subdomain, just like sree in sree.teck.in.
Now, how to remove the www even if a user types it in the address bar of the browser?
[advt]
.htaccess Rewrite
Add the following to your .htaccess file of your Apache web server, which will rewrite the URL removing www part.
RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
PHP / WordPress
If you do not have access to htaccess file, copy the PHP code to top of your wp-config.php file, and replace yourdomain.com with your domain name.
If you do not have access to wp-config.php, you can add these lines on the very top of your header.php in your current theme, within the php tags. Make sure you do not put any extra space in there, which would break your RSS feed otherwise!
If you are using any other PHP CMS, you can still use this code. Just make sure that, this gets executed before any other processing.
if ( strpos($_SERVER['HTTP_HOST'], 'www.') === 0 ) { header('HTTP/1.1 301 Moved Permanently'); header('Location: http://yourdomain.com' . $_SERVER['REQUEST_URI']); exit(); }
For this blog teck.in, I use the php code. If you type the address as https://teck.in/, it will be converted into https://teck.in automatically.
Also, if you are an Search Engine Optimization guy, don’t forget to set the preferred domain for search in the Webmaster Central as the one without the www part.
Why don’t you get rid of www and join the no-www club?
and…if one IS NOT using PHP? and NOT using htaccess? For a hand coded site, not CMS?
thanks for this usefull informations….. now i find what i want to know….. thanks…..
I appreciate the insight, and I think the author definately knows their stuff… has better info than the wiki on the subject!
Excellent post.I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work.
The men who succeed are the efficient few. They are the few who have the ambition and will power to develop themselves.
Wow thats cool, I will give this a try on my own website. cheers!=)
I rather enjoy telling people double-you double-you double-you dot my domain dot com 🙂
Dang
I just entered a long and comprehensive comment, and when I hit the submit button my Internet Explorer hung.
Did you get it or do I need to retype the whole thing?
That’s cool. They should be automatically updating the .htaccess accordingly.
If you are a dreamhost user, they have this option in their control panel.