-1

So I am having an issue where on my webserver if you go to wwww.mydomain.com it works and displays the website, but if you go to mydomain.com it doesn't change or redirect you to www.mydomain.com, so people can be on mydomain.com and www.mydomain.com and they act like different websites, you have to login to both seperately if you login with the wwww and then click a link that has www you have to login again. Its like they are 2 independent websites with the exact same everything. Is it possible to force them to be the same thing? redirect or change some records? Thanks for any info.

Currently my DNS setup is, I have A record @ pointing to my elastic IP. and www CNAME points to @

CMOS
  • 101
  • 4

1 Answers1

3

First and foremost, it's usually recommended that you replace your "domain.com" hosting to be a permanent and visible redirect to "www.domain.com".

Usually, it's done either inside your web panel or in your webserver's configuration file with something similar to that (apache2 example) :

<Virtualhost *:80> 
  ServerName domain.com
  RewriteEngine On 
  RewriteRule ^/(.*)$ http://www.domain.com$1 [R=301,L] 
</VirtualHost>

regarding your login issue, it's likely a cookie problem. If your application is setting a cookie to authenticate your user, this cookie is limited to a fully qualified domain name or a wildcard.

  • a cookie with a limit of domain.com means "only send this cookie when accessing a page on domain.com"
  • a cookie with a limit of .domain.com (mind the dot) means "only send this cookie when accessing a page on domain.com or anything.domain.com"

If you set your application to send a cookie with .domain.com as a domain limiter, it will work both on domain.com and www.domain.com