login community faq

I'm sure the answer to this is so obvious I'll slap my self when I find it.

I have my domain's registered at Hover. On my control panel here I have domain.com and www.domain.com, but I want all traffic to my Web sites to go to the www.domain.com and have any requests to domain.com redirected to the www.domain.com site.

I tried a .htaccess rewrite but it did not seem to work.

1
2
3
4
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC]
RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L]

Help, advice and more importantly what is the best way to do this to avoid having the SEO score effected by traffic going to the www and non www sites.

Thanks,

asked Jan 18 '12 at 23:01

mgd711's gravatar image

mgd711
11

edited Jan 19 '12 at 09:34

seanf's gravatar image

seanf ♦♦
56541220

Johns,

Thanks for the answer but I'll admit I don't fully understand.

I added a second cgi/php app under one of my domains and added an htaccess file in the root of the new app

1
2
3
4
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^anti-lomo.com$ [NC]
RewriteRule ^(.*)$ http://www.anti-lomo.com/$1 [R=301,L]

but this is not working.

Obviously, I don't fully understand what's going on here.

(Jan 18 '12 at 23:27) mgd711 mgd711's gravatar image

Create a second app that just does redirects and put this code in it.

answered Jan 18 '12 at 23:07

johns's gravatar image

johns ♦♦
340427

Johns,

Thanks for the answer but I'll admit I don't fully understand.

I added a second cgi/php app under one of my domains and added an htaccess file in the root of the new app

1
2
3
4
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^anti-lomo.com$ [NC]
RewriteRule ^(.*)$ http://www.anti-lomo.com/$1 [R=301,L]

but this is not working.

Obviously, I don't fully understand what's going on here.

(Jan 18 '12 at 23:33) mgd711 mgd711's gravatar image

The link should explain the whole process step by step, you would than create a second website record and bind the url you wanted redirected to it.

(Jan 18 '12 at 23:50) johns ♦♦ johns's gravatar image

OK... I think I have found the answer, at least it's working for me...

1
2
3
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteRule ^([a-z0-9-\./]+)?$ http://www.%{HTTP_HOST}/$1 [R=301,L]

I created a .htaccess file in the root of the application and when I enter anti-lomo.com the browser directs to www.anti-lomo.com (test site).

answered Jan 18 '12 at 23:47

mgd711's gravatar image

mgd711
11

edited Jan 19 '12 at 09:36

seanf's gravatar image

seanf ♦♦
56541220

Glad to hear you figured something out.

(Jan 18 '12 at 23:49) johns ♦♦ johns's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×19

Asked: Jan 18 '12 at 23:01

Seen: 686 times

Last updated: Jan 19 '12 at 09:36

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited