Redirecting from www cname not working

Advert test
Hi Webmaster experts,
I have installed apache on my windows machine and trying to do a redirect from my site url [noparse][/noparse] to [noparse][/noparse].
We are trying to do this for mobile devices and want to read the type of device accessing it. However this keeps failing and we are not sure how to debug this. I am new to apache so please feel free to point me to a beginners tutorial or reference site. I have tried some google search however the information is overwhelming.
Please feel free to move this thread to right location just in case I have posted this in the wrong place. Thanks in advance.
it's not CNAME you need, it's htaccess.
CNAME needs to be there for www and non www, or just do * , but the htaccess is what you need
.htaccess is what you need

# ----------------------------------------------------------------------
# Start rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

# ----------------------------------------------------------------------
# Suppress or force the "www." at the beginning of URLs
# ----------------------------------------------------------------------

# The same content should never be available under two different URLs - especially not with and
# without "www." at the beginning, since this can cause SEO problems (duplicate content).
# That's why you should choose one of the alternatives and redirect the other one.

# By default option 1 (no "www.") is activated. Remember: Shorter URLs are sexier.

# If you rather want to use option 2, just comment out all option 1 lines
# and uncomment option 2.

# ----------------------------------------------------------------------

# Option 1:
# Rewrite " ->"

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# ----------------------------------------------------------------------

# Option 2:
# To rewrite " ->" uncomment the following lines.
# Be aware that the following rule might not be a good idea if you
# use "real" subdomains for certain parts of your website.

# <IfModule mod_rewrite.c>
#   RewriteCond %{HTTPS} !=on
#   RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#   RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# </IfModule>
Source: html5boilerplate