Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Mar 16, 2011 10:25 am 
Offline
Senior Newbie

Joined: Wed Mar 16, 2011 10:08 am
Posts: 11
let's say, i have a domain example.com

what are the best practices regarding handling names with and without www?

1) redirect requests from www.example.com/anything to example.com/anything
2) redirect requests from example.com/anything to www.example.com/anything

I chose to use the Apache web server. Should i consider using mod_rewrite (RewriteCond / RewriteRule)?

Thanks!


Top
   
 Post subject:
PostPosted: Wed Mar 16, 2011 10:36 am 
Offline
Senior Member

Joined: Mon Oct 27, 2008 10:24 am
Posts: 173
Website: http://www.worshiproot.com
I don't bother redirecting. Let the user use whichever they want.


Top
   
 Post subject:
PostPosted: Wed Mar 16, 2011 11:08 am 
Offline
Senior Member

Joined: Fri Jan 09, 2009 5:32 pm
Posts: 634
JshWright wrote:
I don't bother redirecting. Let the user use whichever they want.


Ditto. Just have the same virtualhost answer both


Top
   
 Post subject:
PostPosted: Wed Mar 16, 2011 12:04 pm 
Offline
Senior Member

Joined: Wed Mar 03, 2010 2:04 pm
Posts: 111
I don't know if there are best practices, but my preference is always to have a subdomain present. I accept both but usually force www with a rewrite. To me it just looks consistent.

Edit: if you accept both, just remember to always set domain-level cookies. If you set a cookie for www.domain.com and the user types in domain.com, the cookies won't work.


Top
   
 Post subject:
PostPosted: Wed Mar 16, 2011 2:27 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
I rewrite to www for analytics purposes.

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Wed Mar 16, 2011 3:29 pm 
Offline
Senior Member
User avatar

Joined: Sun Mar 23, 2008 10:10 am
Posts: 71
Website: http://frontseed.com/
glg wrote:
JshWright wrote:
I don't bother redirecting. Let the user use whichever they want.


Ditto. Just have the same virtualhost answer both

Actually I was told years ago that redirecting might be the proper solution to avoid content duplication penalties from search engines. So I usually redirect.

Doing this to the www or the non-www version is usually up to my clients' requests or the domain name (e.g. whichever 'sounds' better).


Top
   
 Post subject:
PostPosted: Wed Mar 16, 2011 11:22 pm 
Offline
Junior Member

Joined: Sun Feb 14, 2010 5:40 pm
Posts: 28
Definitely rewrite to whatever you prefer. Duplicate links pointing to the same content split the value of of the incoming link and as melon said, duplicate content penalty could be a problem.


Top
   
 Post subject: Thanks, guys!
PostPosted: Thu Mar 17, 2011 8:50 am 
Offline
Senior Newbie

Joined: Wed Mar 16, 2011 10:08 am
Posts: 11
Thanks, guys!

I decided to rewrite to example.com w/o www.

My config looks as follows:
Code:
<VirtualHost example.com:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot "/var/www/sites/example.com/current/public"
    ErrorLog "/var/log/apache2/example.com-error_log"
    CustomLog "/var/log/apache2/example.com-access_log" common
    <Directory "/var/www/sites/example.com/current/public">
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    RewriteEngine On
    # Remove the www
    RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
    RewriteRule ^/(.*)$ http://example.com/$1 [L,R=301]
</VirtualHost>


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group