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.

  • Can you share your existing setup? Jan 19 '12 at 13:14

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.


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]
  • thank you very much it worked. and one more additional clarification if I may ask. If I wanted to add multiple domains to htaccess in similar way do I do same thing for each domain or i can use one command and stack urls in one row? Jan 19 '12 at 19:31
  • @Manfred: Yes, for multiple domains you can essentially stack them. I've updated my answer with example code for multiple domains.
    – MrWhite
    Jan 22 '12 at 16:22
  • If this answered your question, then please mark it accepted (tick/checkmark on the left below the voting arrows) to remove it from the unanswered question queue and to help other readers. Once you have 15+ rep then you can also upvote answers you find useful. Thanks, much appreciated. :)
    – MrWhite
    Sep 2 '19 at 14:32

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.