Forcing a non WWW version with DNS records

TacoCat

Bueno...
BuSo Pro
Joined
Apr 2, 2015
Messages
502
Likes
558
Degree
2
Is it possible to force a non WWW version with DNS records?

I'm using the shopify platform and right now I have two domain version with www and without www. I think this might cause some problems. I don't have access to the htaccess file so I can't do a 301, so it comes down to my question.

Maybe there is some other way that I'm not aware of.

Right now my A record is set
Hostname: Domain.com
IP: 11.111.11.11 <- the shopify IP

and CNAME record

Hostname: domain.com
Alias: www.domain.com

I'm probably doing something wrong here. :D
 
Is it possible to force a non WWW version with DNS records?

Unfortunately, that's not a function of DNS. With that being said, some DNS providers offer a forwarding option that would allow you to forward the non www to the www and vice-versa. Since you don't have access to the actual server, you could also contact Shopify and see if they can do the redirect on their side. A search for "shopify non www" yields possible results.

Pro tip: .htaccess should only be used as a last resort if you have full access to the server. That file is read and processed every single request (think high traffic sites here). For things like forwarding www or non-www to the other, blocking user-agents, etc you'll want to put that in the config file for the vhost because that file is read into memory when apache is restarted which means it's only read once.
 
Thanks for the explanation, now at least it is clear to me.

I found a solution, if anyone ever runs into this problem again.

Under Online store, go to the Domains section and there is an option to set a primary domain. It is set to yourname.shopify.com, if you've already set your domain then you will have an option to choose between www and a non www version, just pick which one you want in a drop down and it will automatically set up the redirect.
 
Back