5

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.

2

2 Answers 2

3

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.

2
  • i put that in my .htaccess and now i cant stop it from redirecting my site to www.website.com
    – john-jones
    Commented Oct 11, 2012 at 6:58
  • And the solution to that is to clear my browsers cache.
    – john-jones
    Commented Oct 11, 2012 at 7:14
0
  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 https://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.

4
  • Your point 2 is incorrect, there is a technical difference, and it has to do with DNS NS and CNAME records.
    – Greg Hewgill
    Commented Apr 9, 2011 at 20:41
  • @Greg, that's really what I'm looking for.
    – Andrew
    Commented Apr 9, 2011 at 20:44
  • @Andrew: Please see the answers to the question I linked over on Server Fault.
    – Greg Hewgill
    Commented Apr 9, 2011 at 20:47
  • @Greg: I wasn't aware of that, I linked it.
    – Femaref
    Commented Apr 9, 2011 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.