I'm having trouble understanding why sometimes my URL works with the www prefix and NOT without www. And sometimes it's just the other way around.
I'm using: Apache/2.4.59 on Fedora 39 with certbot 2.10.0 and have full acces with a root shell
Currently the URL DOES work with the www prefix and NOT without www
I've read a lot of documentation
(incl. Www needs to be redirected to non www )
and tried a lot but unfortunately with no succes
I'm looking for a hint to get me in the right direction
Tnx in adv.
Below are, in my opinion, the relevant pieces of code,
The last bit is a error massage from a online SSL checker
==========================================
httpd -t
Syntax OK
==========================================
output: Creation of Let'sEncrypte SSL certificate
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/crossway.nl/fullchain.pem
Key is saved at: /etc/letsencrypt/live/crossway.nl/privkey.pem
This certificate expires on 2024-08-27.
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 crossway.nl to /etc/httpd/conf/httpd-le-ssl.conf
Successfully deployed certificate for www.crossway.nl to /etc/httpd/conf/httpd-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://crossway.nl and https://www.crossway.nl
==========================================
part of etc/httpd/conf
<VirtualHost *:80>
DocumentRoot /var/www/crossway.nl
ServerName www.crossway.nl
ServerAlias crossway.nl
ServerAdmin email@crossway.nl
ErrorLog logs/virtual.crossway.host-error_log
CustomLog logs/virtual.crossway.host-access_log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.crossway.nl [OR]
RewriteCond %{SERVER_NAME} =crossway.nl
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Include /etc/httpd/conf/httpd-le-ssl.conf
==========================================
part of etc/httpd/httpd-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot /var/www/crossway.nl
ServerName www.crossway.nl
ServerAlias crossway.nl
ServerAdmin mike@crossway.nl
ErrorLog logs/virtual.host-error_log
CustomLog logs/virtual.host-access_log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/crossway.nl/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/crossway.nl/privkey.pem
</VirtualHost>
</IfModule>
==========================================
part of .htaccess file in /var/www/abc.nl
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
##------Force HTTPS connections on entire domain ------##
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
##
==========================================
sudo cat /etc/letsencrypt/live/abc.nl/fullchain.pem
sudo cat /etc/letsencrypt/live/www.abc.nl/fullchain.pem
both commands can parse the .pem files
-----BEGIN CERTIFICATE-----
MIIEKD ..... g54iJ+gy
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFFjC ...... q7hHwg
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFYDC ....... y753ec5
-----END CERTIFICATE-----
==========================================
Error message from SSL Checker
The certificate is not trusted in all web browsers. You may need to install an Intermediate/chain certificate to link it to a trusted root certificate. Learn more about this error. The fastest way to fix this problem is to contact your SSL provider.
None of the common names in the certificate match the name that was entered (crossway.nl). You may receive an error when accessing this site in a web browser. Learn more about name mismatch errors.