Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.

share|improve this question

migrated from webapps.stackexchange.com Jan 19 '12 at 6:20

This question came from our site for power users of web applications.

    
Can you share your existing setup? –  toomanyairmiles Jan 19 '12 at 13:14
add comment

1 Answer 1

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]
share|improve this answer
    
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? –  Manfred von Richthofen 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. –  w3d Jan 22 '12 at 16:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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