Remove WWW from your Domain Name / Website URL

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, the website of Vatican City. .va is the TLD (top level domain) assigned to Vatican City. Does the domain name seem to miss the domain name, like 🙂 Nope. Here www is the domain label, and the regular www subdomain is not used. Clear?

For example, in case of, technically the www is nothing but a subdomain, just like sree in

Now, how to remove the www even if a user types it in the address bar of the browser?


.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 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:' . $_SERVER['REQUEST_URI']);

For this blog, I use the php code. If you type the address as, it will be converted into 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?

Be the first to comment

Leave a Reply