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

I'm getting ready to deploy my Rails app. Currently whether you browse to it using www.domain.com or just domain.com you get the same site.

I'm pretty new at this, so I'm looking for some wisdom from experienced web app developers:

Is it worth forcing requests to either WWW or non-WWW? It seems there are apps that go either way...

I know that this kind of question is in danger of being too subjective, but to help keep it objective here's a few specific questions that I'd really appreciate answers to:

  1. Does your web app force requests to WWW or root domain, or does it allow both equally?
  2. What technical reasons are there for choosing one option or the other (honestly I don't know if it even makes a difference).
  3. If you were building a new web app today, which option would you choose?

I appreciate any advice.

--EDIT--

To reiterate what I'm looking for as distinct from this question are there specific ramifications for web applications that I should be aware of before I make a decision and deploy? In particular if any Rails developers have had issues related to one option or the other that would be really helpful to know.

share|improve this question

migrated from stackoverflow.com Apr 9 '11 at 20:56

This question came from our site for professional and enthusiast programmers.

    
There are a lot of good answers for this question over on Server Fault: What’s the point in having “www” in a URL? –  Greg Hewgill Apr 9 '11 at 20:39
    
possible duplicate of WWW or not WWW, what to choose as primary site name? –  Greg Hewgill Apr 9 '11 at 20:53
add comment

2 Answers 2

Use www as the default one and force redirect to www with this htaccess script:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.WEBSITE.com$
RewriteRule ^(.*)$ http://www.WEBSITE.com/$1 [R=301]

This way you avoid duplicate content on Google.

share|improve this answer
    
i put that in my .htaccess and now i cant stop it from redirecting my site to www.website.com –  Hermann Ingjaldsson Oct 11 '12 at 6:58
    
And the solution to that is to clear my browsers cache. –  Hermann Ingjaldsson Oct 11 '12 at 7:14
add comment
  1. I don't currently have an active one, but if I had, I would allow both, but redirect from www to simply http://
  2. there is a difference, see http://serverfault.com/questions/145777/whats-the-point-in-having-www-in-a-url
  3. I would make the non-www the default, but would redirect if somebody requested the www one.

edit I wasn't aware of the DNS issue.

share|improve this answer
    
Your point 2 is incorrect, there is a technical difference, and it has to do with DNS NS and CNAME records. –  Greg Hewgill Apr 9 '11 at 20:41
    
@Greg, that's really what I'm looking for. –  Andrew Apr 9 '11 at 20:44
    
@Andrew: Please see the answers to the question I linked over on Server Fault. –  Greg Hewgill Apr 9 '11 at 20:47
    
@Greg: I wasn't aware of that, I linked it. –  Femaref Apr 9 '11 at 20:49
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.