Without www my sites workes fine, without I can't login with my username and password.

May 27, 2014 1.2k views
Hello, When I log in to my site WITHOUT www. it works fine, but whenever I visit the site with www. the same username and password don't seem to work. I added www as a A record in the DNS, without it I could even only visit the website without www. It's hosted on Ubuntu 14.04 and the application is written in Ruby on Rails.
1 Answer
Right, to access www.your-domain.tld you need to set up either an A record or CNAME pointing to it. Your password issue is perplexing though. I'm having a hard time imagining what would cause that! I'd suggest redirecting the www subdomain back to the main one, as it's usually a good idea to pick one or the other either way.

Since you're using Rails, I imagine you're also using Nginx? Edit your configuration to add a new server block that sets up a redirect from www to the root domain. It would look something like:


server {
listen 80;
server_name www.your-domain.tld;
return 301 http://your-domain.tld$request_uri;
}

server {
listen 80;
server_name your-domain.tld;
# And whatever else....
}
Have another answer? Share your knowledge.