-2

I want this:

  • www.example.com -> https://www.example.com
  • example.com -> https://www.example.com

Here are my URL Redirects Record

Record 1

  • Host: www
  • Value: https://www.example.com/

Record 2

  • Host: @
  • Value: https://www.example.com/

Now, when I try to add CNAME record

  • Host: www
  • Value: @

Namecheap's DNS manager page says, using naked domain will prevent mails from being sent to the domain. (I am using privateemail from Namecheap)

(I do have an A record for ipaddress)

So how can I get the browser to resolve https://www.example.com without breaking my email?

vjjj
  • 117
  • 4
  • Possible duplicate of [Why can't a CNAME record be used at the apex (aka root) of a domain?](https://serverfault.com/questions/613829/why-cant-a-cname-record-be-used-at-the-apex-aka-root-of-a-domain) – Jenny D Jul 17 '17 at 07:30

4 Answers4

1

A and CNAME records are typically irrelevant for email, so long as an MX record exists. Set your MX records correctly for the base domain (not the www subdomain) to point to your email server and it'll be fine.

Your server can of course do both email (via MX records) and web (via CNAME / A records), but you can also have them separate. Many people for example use Office 365 or Google for email hosting, completely separately from their web hosting.

Tim
  • 30,383
  • 6
  • 47
  • 77
1

You can simply add an A record for the www in your DNS configuration. It doesn't have to be CNAME, and A record saves DNS resolve requests too.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
0

You will need your web server or web application to handle the redirection to HTTPS based on the protocol used by the connecting client. I recommend doing a permanent redirection (Apache HTTPD config sample):

Redirect Permanent / https://yourdomain.com/

This is so, if supported, your connecting clients will connect using HTTPS for future connections after being redirected once.

As for your DNS, you will only need your website domain's A record to the address of your web server and this should already cover for both HTTP and HTTPS traffic.

0

Another workaround, create an .htaccess file in your public folder with the following content:

RewriteEngine on RewriteCond %{HTTP_HOST} ^yourdomain.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC] RewriteRule ^(.*)$ http://yournewdomain.com/$1 [L,R=301,NC]

Change yourdomain.com and www.yourdomain.com to your existing domain and yournewdomain.com to your new domain

Goodluck