With or Without WWW

Folks, some of you have might have a website. For example you develop http://www.google.com (OF COURSE this is just an example :)). You might have a question, whether use http://google.com (w/o “www”), or http://www.google.com (w/ “www”). I don’t suggest that “www” is better, vice versa. But i’ll tell it about how to use with only, or without only.

The key is, you must create a .htaccess file in your root directory (or modify the old one if you’ve had it)

If you choose with www, use it in your .htaccess file


  RewriteEngine on

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

If you choose without www, use it in your .htaccess file


  RewriteEngine on

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

Note : Your server must support rewrite module.


Comments

2 responses to “With or Without WWW”

  1. ghprod Avatar
    ghprod

    ternyata buanyak bgt yg harus dpelajari yaks ?

    wish me luck bro ๐Ÿ™‚

  2. Hehe sip bro ๐Ÿ˜€

Leave a Reply

Your email address will not be published. Required fields are marked *