With or Without WWW on domain name
With or Without WWW on domain name which is best??
When you write a URL for your website, it can be written with or without “www,” like this:
* http://log.xmodx.com/
* http://log.xmodx.com/
Should you include “www” with your URL?
The same and not the same
With most websites, the URLs with and without “www” in them will point to the same site. However, you can specify each URL (with and without “www”) to point to a different IP address by modifying your DNS A record.
Choose www or no www
Some search engines see the above two URLs as two different URLs. Each URL can have a different PageRank, and by using both, you’re diluting the PR for each URL.
For PR and SEO purposes, it’s preferable to choose one version or the other to use. There are reasons for each choice. Which one you choose depends mostly on personal preference.
Reasons to include www
* It helps identify a URL as a web address, especially if the domain extension is other than a .com one.
* Many people will type it in anyway.
* For some people, URLs look more visually appealing with them.
Reasons not to include www
* It makes the URL longer, especially if the URL is for a subdomain.
* It’s unnecessary.
* For some people, URLs look cleaner without them.
How to redirect from one to the other using .htaccess
If your site is on an Apache server, you can choose to have only the version with or without “www” appear. One will direct to the other. Add one of the following to your .htaccess file after replacing “example.com” with your domain. The “RewriteEngine on” first line activates mod_rewrite.
To redirect to the URL with www
RewriteEngine On
rewriteCond %{HTTP_HOST} ^xmodx.com [NC]
rewriteRule ^(.*)$ http://log.xmodx.com/$1 [R=301,L]
( https version )
RewriteCond %{HTTP_HOST} ^xmodx\.com
RewriteCond %{HTTPS} =on
RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^xmodx\.com
RewriteCond %{HTTPS} !=on
RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
To redirect to the URL without www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.xmodx\.com$ [NC]
RewriteRule ^(.*)$ http://log.xmodx.com/$1 [R=301,L]