SSL works with www and not without www

I have migrated a wordpress website from siteground to Linode using Duplicator plugin. Website worked fine. When I tried to install SSL using Let's Encrypt and made changes to my wordpress settings to load it over https://www.cscdigital.tv, The website is only working over https://www.cscdigital.tv and does not want to work over https://cscdigital.tv
My domain is:
cscdigital.tv
I ran this command:
sudo certbot --apache
It produced this output:
Saving debug log to /var/log/letsencrypt/letsencrypt.log

Which names would you like to activate HTTPS for?


1: cscdigital.tv
2: www.cscdigital.tv


Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):
Requesting a certificate for cscdigital.tv and www.cscdigital.tv

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/cscdigital.tv/fullchain.pem
Key is saved at: /etc/letsencrypt/live/cscdigital.tv/privkey.pem
This certificate expires on 2021-10-22.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for cscdigital.tv to /etc/httpd/sites-available/cscdigital.tv-le-ssl.conf
Successfully deployed certificate for www.cscdigital.tv to /etc/httpd/sites-available/cscdigital.tv-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://cscdigital.tv and https://www.cscdigital.tv


If you like Certbot, please consider supporting our work by:


My web server is (include version):
Server version: Apache/2.4.37 (centos)
Server built: May 20 2021 04:33:06

The operating system my web server runs on is (include version):
CentOS 8
My hosting provider, if applicable, is:
Linode
I can login to a root shell on my machine (yes or no, or I don't know):
yes
I'm using a control panel to manage my site (no, or provide the name and version of the control panel):
no
The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot):
certbot 1.17.0

the output of sudo httpd -S:

VirtualHost configuration:
*:80 www.cscdigital.com (/etc/httpd/sites-available/cscdigital.tv.conf:6)
*:443 is a NameVirtualHost
default server cscdigital.tv (/etc/httpd/conf.d/ssl.conf:40)
port 443 namevhost cscdigital.tv (/etc/httpd/conf.d/ssl.conf:40)
port 443 namevhost www.cscdigital.tv (/etc/httpd/sites-available/cscdigital.tv-le-ssl.conf:2)
alias cscdigital.tv
port 443 namevhost www.cscdigital.tv (/etc/httpd/sites-available/cscdigital.tv-le-ssl.conf:2)
alias cscdigital.tv
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex cache-socache: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/etc/httpd/run/" mechanism=default
PidFile: "/etc/httpd/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48

1 Like

Have you tried restarting your server? Currently it's serving your default certificate self-singed by linode, not a Let's Encrypt certificate.

1 Like

Here's your problem: your main domain without www is also configured in ssl.conf, which is used over the virtualhost generated by Let's Encrypt.

Also, for some reason you seem to have requestes a new certificate after the certbot output you've shown above, but now just for cscdigital.tv.. Due to that, your www subdomain, which is missing from the certificate, is now giving certificate errors too.

You should reinstall (not reissue!) the certificate with both hostnames again and disable the ssl.conf configuration.

2 Likes

hmm. Thanks for the answer, so should I simply delete this file?

1 Like

Or change its ServerName to something else like localhost or example.com, something not being used on the world wide web. Perhaps the configuration file contains some good default configuration values you don't want to disable.

2 Likes

I just removed site-available directory from the server and copied *.conf files inside the /etc/httpd/conf.d/ directory. Everything is fine now. thanks

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.