Https www KO non-www OK on wordpress


#1

Hello,

I have a self hosted CentOS 7 server with apache and wordpress.
Everything works and it’s set up to work without www so http://mydomain.com
On my dns i set up a CNAME just to be sure so www.mydomain.com redirect to mydomain.com

today i ran (WRONG because of www)
./letsencrypt-auto --apache -d www.mydomain.com
and select “2” to automatic redirect all traffic to https
and i start receive SSL_ERROR_BAD_CERT_DOMAIN trying to visit my website

when i noticed the mistake i run again the correct command
./letsencrypt-auto --apache -d mydomain.com
without www and tried to revoke and delete the first certificate with the www

now i’m in this situation:
http://mydomain.com redirect to https://mydomain.com and works!
https://mydomain.com works!
http://www.mydomain.com redirect to https://www.mydomain.com and DO NOT WORK
https://www.mydomain.com DO NOT WORK

(DO NOT WORK means I receive certificate error, with a “continue anyway” i can see website)

Best way to solve this? I don’t wanna destroy server with a wrong command and I’m not an expert so please explain me a bit how to move and where to check
Many thanks


#2

Use both hostnames (with and without www) on the ./letsencrypt-auto` command to get a certificate with both.

You could also have used both certificates separately, but you say you’ve already deleted the certificate with www.


#3

Just tried, no success.

./letsencrypt-auto --apache -d www.mydomain.com


Congratulations! You have successfully enabled https://www.mydomain.com

Now not only the www problem is not solved but even the non-www is broken. I cannot visit my website anymore.


#4

Re-read @Osiris’ post:


#5

You mean

./letsencrypt-auto --apache -d www.mydomain.com mydomain.com

?
no separator between addresses?


#6

The command should look like this…

./letsencrypt-auto --apache -d www.mydomain.com -d mydomain.com

Thank you


#7

i deleted both old certificate and execute command:

./letsencrypt-auto --apache -d www.mydomain.com -d mydomain.com

but with this result:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running apachectl configtest.

AH00526: Syntax error on line 15 of /etc/httpd/conf.d/old_mywebsite-le-ssl.conf:
SSLCertificateFile: file ‘/etc/letsencrypt/live/www.mywebsite.com/cert.pem’ does not exist or is empty

The apache plugin is not working; there may be problems with your existing configuration.
The error was: MisconfigurationError(“Error while running apachectl configtest.\n\nAH00526: Syntax error on line 15 of /etc/httpd/conf.d/old_mywebsite-le-ssl.conf:\nSSLCertificateFile: file ‘/etc/letsencrypt/live/www.mywebsite.com/cert.pem’ does not exist or is empty\n”,)

line 15 of /etc/httpd/conf.d/old_mywebsite-le-ssl.conf still point to a directory that doesn’t exist anymore…


#8

file ‘/etc/letsencrypt/live/www.mywebsite.com/cert.pem’ does not exist or is empty

That may be your error -> so you have to start new.


#9

I agree, but the command

./letsencrypt-auto --apache -d www.mydomain.com -d mydomain.com

shouldn’t start everything from zero? How to delete every attempt and exceute the command in a clean environment? thanks for your patience guys


#10

If you delete the files ending with le-ssl.conf in /etc/httpd/conf.d/ (backing up the existing files is always a good idea!), you should be able to start “fresh”.


#11

IT WORKS!

i moved the le-ssl.conf and mydomain.conf in another folder, recreate a new conf file for virtual host with port 80 and execute the command. It worked flawless.

Many thanks guys


#12

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