How to redirect root domain to www subdomain?

This article gives a couple of links to articles that explain the redirection in great detail and also provides a ruleset for Saurus CMS.

Articles about redirection

If you don't know exactly what you're doing, contact server administrator or hosting provider.

Redirect rules in Saurus CMS

  1. Your web server should have Apache URL Rewrite Engine module (mod_rewrite), most servers do.
  2. Set up rewrite rules for aliases as guided on page www.saurus.info/configuring-alias-module
  3. Include redirecting rules before alias rules, that's the only way Saurus CMS aliases keep working

Example of alias rerwite rules together with redirecting rules in .htaccess file:

Options +SymLinksIfOwnermatch

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

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}  !^/admin
RewriteCond %{REQUEST_FILENAME} !^/classes
RewriteCond %{REQUEST_FILENAME} !^/editor
RewriteCond %{REQUEST_FILENAME}  !^/extensions
RewriteCond %{REQUEST_FILENAME} !^/idcard
RewriteCond %{REQUEST_FILENAME} !^/js
RewriteCond %{REQUEST_FILENAME}  !^/public
RewriteCond %{REQUEST_FILENAME} !^/px
RewriteCond %{REQUEST_FILENAME} !^/px_custom
RewriteCond %{REQUEST_FILENAME}  !^/shared
RewriteCond %{REQUEST_FILENAME} !^/styles
RewriteRule ^/(.*) /map.php?mod_rewrite=/&cmd=$1  [L,PT,QSA]

# RewriteLogLevel 0 will disable logging, we suggest set it to 2 
# for debugging problems
RewriteLogLevel 0

# set correct log file path  here, we suggest set it only when debugging problems:
# RewriteLog  /var/log/httpd/rewrite.log