Point naked URL to www in cPanel

by Manfred von Richthofen   Last Updated September 10, 2019 22:04 PM

Simply I am trying to do this:

When a person types myurl.com it will convert into www.myurl.com and when person types www.myurl.com it stays www.myurl.com (mainly I want to do this for search engine optimization, so Google doesn't think I have 2 domains, naked and with www.)

I am pointing DNS from Netfirms to my website hosted at another hosting company that uses Litespeed on Linux instead of Apache.

Control panel is cPanel and I have access to DNS management on server through it.

As I know it has something to do with A records, and that's how much I know. Please be specific if you're going to answer.

Tags : dns cpanel


Answers 2


As far as I'm aware, Litespeed also supports mod_rewrite in .htaccess files. So, if you don't already have a file called ".htaccess" in the public root of your website, create it and insert the following script...

For single domains

Options +FollowSymLinks        # Must be enabled if not already
RewriteEngine On

# Redirect none WWW to WWW
RewriteCond %{HTTP_HOST} ^myurl\.com
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]

As far as Google is concerned, you can specifically tell Google which version (www or none www) of your site you would prefer in search results within Google Webmaster Tools. You just need to register your site if you haven't already. If you had already done the .htaccess method then you don't necessarily have to explicitly tell Google as it will pick it up.

This solution obviously doesn't add any additional DNS entries.

...EDIT...

For multiple domains

Options +FollowSymLinks        # Must be enabled if not already
RewriteEngine on

# Redirect none WWW to WWW - Multiple domains
RewriteCond %{HTTP_HOST} ^example\.com [NC,OR] 
RewriteCond %{HTTP_HOST} ^another\.com [NC] 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
MrWhite
MrWhite
January 19, 2012 12:13 PM

The answer with the redirect is correct, I just wanted to add the DNS setup also.

CNAME www.myurl.com    myurl.com<br>
A       @.myurl       ip.add.re.ss 

There are other ways probably, and the wildcard character might be different, but this is the basic setup for showing a non-www TLD.

If you use www and a CNAME you may run into trouble verifying domain services (like Google Search Console) on that node because CNAME only allows one record.

keepkalm
keepkalm
September 10, 2019 21:05 PM

Related Questions


Updated April 30, 2015 21:01 PM

Updated May 25, 2015 22:01 PM

Updated June 29, 2015 19:01 PM

Updated July 23, 2015 13:01 PM