By Dittobox
I recently moved a website from Dreamhost to an Ubuntu LEMP droplet. Much, much faster. This also allowed us to enable HTTPS using our preexisting wildcard certficate. I’ve setup a redirect to move all incoming traffic on http://[www.]domain.tld:80 to https://[www.]domain.tld:443 like so:
server {
listen 80;
server_name domain.tld www.domain.tld;
return 301 https://domain.tld$request_uri;
}
This works really well. Too well! I still have a few subdomains hosted at Dreamhost, which are HTTP only. Now any browser that first visits domain.tld always prefixes https:// instead of http://. I understand this working on the explicit www.domain.tld and domain.tld, but why is this 301 redirect being applied by browsers to all subdomains? Is there anyway to do this differently so that unspecified subdomains are not included in the 301?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This question was answered by @sleepdreaming:
How are your subdomains configured in your DNS? If they are CNAMES then there will be a conflict since you moved your main domain.tld to another server (and another IP of course). If they ARE CNAMES then you need to change them to A records with the IP address of your previous server so they will resolve to that IP instead of your DO droplet.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.