I'm using DigitalOcean for my hosting services and I've several domain names on the same droplets. All these domain use Let's Encrypt for SSL certificates.
What's your DNS records ?
|--------|---------------------------|--------------------------------------------|---------------|
| Type | Hostname | Value | TTL (seconds) |
|--------|---------------------------|--------------------------------------------|---------------|
| NS | example.com | ns1.digitalocean.com. | 1800 |
| NS | example.com | ns2.digitalocean.com. | 1800 |
| NS | example.com | ns3.digitalocean.com. | 1800 |
| A | example.com | 159.xx.xx.60. | 3600 |
| A | www.example.com | 159.xx.xx.60. | 3600 |
| MX | example.com | mailstore1.secureserver.net. | 14400 |
| MX | example.com | smtp.secureserver.net. | 14400 |
| CNAME | 12501762.example.com | sendgrid.net. | 43200 |
| CNAME | url9338.example.com | sendgrid.net. | 43200 |
| CNAME | s2._domainkey.example.com | s2.domainkey.u12501762.wl015.sendgrid.net. | 43200 |
| CNAME | s1._domainkey.example.com | s1.domainkey.u12501762.wl015.sendgrid.net. | 43200 |
| CNAME | em8980.example.com | u12501762.wl013.sendgrid.net. | 43200 |
|--------|---------------------------|--------------------------------------------|---------------|
MX = allow the use of the GoDaddy mailbox (email like abc@example.com).
CNAME = allow the use of SendGrid.
So what's my problem?
If I type in the browser:
example.com, I have a 404 error saying Apache/2.4.29 (Ubuntu) Server at example.com Port 80.
www.example.com, all is working and it redirects to the HTTPS version.
http://example.com, all is working and it redirects to the HTTPS version.
https://example.com, all is working.
So the problem is only with example.com.
Did you try ping function?
Yes. I ping with www.example.com and example.com and the both gave me the same IP address (my IP address).
What about traceroute ?
Again, it gave me the same for both www.example.com and example.com. It pointed to my server.
What about my .conf files?
Here the example.com.conf file:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com [OR]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Here the example.com-le-ssl.conf file:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>
Can anyone help me with this ?
Thanks for any help.
Redirect
directive instead ofRewrite
rules for the redirection, as it is shown here: https://askubuntu.com/a/1031460/566421 Then flush your browser's cache ot use a new incognito window to do the test. – pa4080 Sep 27 '19 at 05:17