Forum Moderators: phranque

Message Too Old, No Replies

keeping the "www"

redirection to keep the www in the URL

         

feralo

3:57 pm on Apr 14, 2006 (gmt 0)

10+ Year Member



I have been told that having a site that allows people to type in "website.com"or "www.website.com" can get indexed twice and that it is bad for search engine stuff. i was also told to look into 301 redirect to solve this problem. I have not gotten it to work and i am thinking that this problem may require a different solution.
Any ideas?

milanmk

4:36 pm on Apr 14, 2006 (gmt 0)

10+ Year Member



As you have not mentioned in your post what solutions you have used to achieve this here is a simple solution; add the following code to your htaccess file for redirecting non WWW url's to WWW ones.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [L,R=301]

Hope this helps.

Milan

[edited by: jdMorgan at 3:12 am (utc) on April 15, 2006]
[edit reason] Fixed missing space before "!" [/edit]

feralo

4:47 pm on Apr 14, 2006 (gmt 0)

10+ Year Member


Thank you for the quick reply.
However this does not redirect the visitor to http://www.website.com
as far as i can tell it would just allow a re-written url.
what i am trying to do is redirect all traffic that types in website.com (http://website.com) to http://www.website.com.

milanmk

4:56 pm on Apr 14, 2006 (gmt 0)

10+ Year Member



feralo this will certainly do that, give it a try. I am using this code since last 2 years and its working great, both for bots and for direct URL typing in browser.

Milan