url with www. or without

Discussion in 'Web Hosting' started by j1a4l0, Mar 12, 2010.

  1. #1
    Hi guys,

    I have faced a problem. I have hosted a php website on the server and when I sometimes (depend on the browser and computer) try to call 'www.domainname.com' it returns a not found page. It has never happened when I type in with the 'www'. Also, there is someone in charge of the SEO and he is saying that the search robots are finding duplicates URL such as:

    http://www.domainname.com
    http://domainname.com

    http://www.domainname.com/index.php
    http://domainname.com/index.php

    so I would like to know how I could better sort it out. I believe I should disable the direct url without the 'www' but I have no idea how to do it if it is by .ht file or how.

    Thanks in advance
     
    j1a4l0, Mar 12, 2010 IP
  2. digital29

    digital29 Peon

    Messages:
    462
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I usually redirect non-www to www...but you can choose..i`ll put some code below which you can use in the .htaccess file

    Redirect WWW to non-WWW:

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

    Redirect Non-WWW to WWW:

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

    I`ve find them on google..just choose whatever you want and replace "example" with your domain
     
    digital29, Mar 12, 2010 IP
  3. joshvelco

    joshvelco Peon

    Messages:
    819
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It may be a slow connection. But to sort out the problem with duplicate content, use a 301 redirect, google it and redirect all content to the www. version. This will mean that if you type yourdomain.com it will automatically go to www.yourdomain.com. Search engines are included under this rule so it will not detect duplicate content.
     
    joshvelco, Mar 12, 2010 IP
  4. j1a4l0

    j1a4l0 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you guys for your replies.
    Just on more question to joshvelco, how do I exactly do it (use a 301 redirect, google it and redirect all content to the www. version)?
     
    j1a4l0, Mar 12, 2010 IP
  5. alldaylinks

    alldaylinks Active Member

    Messages:
    692
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    85
    #5
    Personally I always stick to keeping the www.

    Just tradition really... no rules
     
    alldaylinks, Mar 12, 2010 IP
  6. alldaylinks

    alldaylinks Active Member

    Messages:
    692
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    85
    #6
    alldaylinks, Mar 12, 2010 IP
  7. wholesaleguru

    wholesaleguru Guest

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    This all depends on whether you are running your own server, have dedicated managed hosting, or shared hosting. As far as I'm aware the inclusion of the www. prefix is optional and inconsequential with very few exceptions. Problems like yours are rare (at least to my own knowledge and experience). You could try a redirect as suggested, but I think your best bet (if you have managed hosting) is to call your web hosting service and alert them to this problem, and while you're at it you might want to try calling your domain name registrar because it could be something to do with where and how you parked your domain or your dns name servers.
     
    wholesaleguru, Mar 12, 2010 IP
  8. inspiroHost

    inspiroHost Peon

    Messages:
    989
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    My preference is also for the www.
     
    inspiroHost, Mar 14, 2010 IP
  9. sanhit

    sanhit Peon

    Messages:
    318
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    If you are using Cpanel u can do the Permanent Redirect with easy steps. No coding required.
     
    sanhit, Mar 19, 2010 IP
  10. Ethan8

    Ethan8 Peon

    Messages:
    200
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Did you set nameservers for your domain name or custom records? Make sure to point www to the IP of your webhost if you use custom records.
     
    Ethan8, Apr 5, 2010 IP
  11. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #11
    It's best and preferred to do both.

    I'd suggest picking up a copy of Oreilly and Associates "DNS and BIND".
     
    Mia, Apr 6, 2010 IP
  12. Mystique

    Mystique Well-Known Member

    Messages:
    2,579
    Likes Received:
    94
    Best Answers:
    2
    Trophy Points:
    195
    #12
    I would suggest stick to either version and depending on your domain name decided on wwww or non-www.
    Some domains make better URLs without the www, such as the INFO domains


    Here both redirection rules:

    
    
    WITH WWW:
    
    
    RewriteEngine On
     
    RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC] 
    RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
    
    
    
    WITHOUT WWW:
    
    
    RewriteEngine On
     
    RewriteCond %{HTTP_HOST} ^www.yourdomain\.com$ [NC] 
    RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]
    
    
    
    
    Code (markup):
     
    Mystique, Apr 6, 2010 IP
  13. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #13
    Regardless of what might look better or sound better phonetically, people will type it both ways. If they type www and you have no A Record or CNAME/vhost, they will likely think you went poop and go someplace else, and visa versa.
     
    Mia, Apr 6, 2010 IP
  14. Internal09

    Internal09 Member

    Messages:
    256
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    35
    #14
    Its a 301 redirect based on your and .htaccess.
     
    Internal09, Apr 6, 2010 IP
  15. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #15
    Its really more efficient to simply ad it as an alias both in your zone file and vhost config. No need to ad the redirect. Its just one more step.
     
    Mia, Apr 6, 2010 IP
  16. rakker126

    rakker126 Peon

    Messages:
    209
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #16
    You can use webmaster center of Google as well, it' s really seasy in the config.
     
    rakker126, Apr 9, 2010 IP
  17. 4ankurc

    4ankurc Peon

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    this problem was only in internet explorer but such type of error cant seen in mozilla
     
    4ankurc, Apr 9, 2010 IP
  18. extraldonary

    extraldonary Well-Known Member

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    106
    #18
    I think wordpress automaticaly forward www and non-www domain to one that you choose
     
    extraldonary, Apr 18, 2010 IP
  19. rakker126

    rakker126 Peon

    Messages:
    209
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #19
    I use the non version my self, in Google Webmaster Center i set my preference and you can change it in your .htacces for a 301 redirect.
     
    rakker126, Apr 20, 2010 IP