All vhosts redirecting to roo domain

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. https://crt.sh/?q=example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is:
soledadmining.com
I ran this command:
certbot
It produced this output:
allowed me to choose which domain
My web server is (include version):
Apache2
The operating system my web server runs on is (include version):
ubuntu 18.04
My hosting provider, if applicable, is:
digital ocean VPS
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): 0.31.0

I have two vhosts:
www.soledadmining.com (/var/www/html)
staging.soledadmining.com (/var/www/staging)

vhost for WWW is www.soledadmining.com.conf
vhost for staging is staging.soledadmining.com.conf

contents of www-conf:

<VirtualHost *:80>
ServerAdmin scott@scottplude.com
ServerName www.soledadmining.com
ServerAlias www.soledadmining.com
DocumentRoot /var/www/html
ErrorLog {APACHE_LOG_DIR}/error.log CustomLog {APACHE_LOG_DIR}/access.log combined

contents of staging-conf:
<VirtualHost *:80>
ServerAdmin scott@scottplude.com
ServerName staging.soledadmining.com
ServerAlias staging.soledadmining.com
DocumentRoot /var/www/staging
ErrorLog {APACHE_LOG_DIR}/error.log CustomLog {APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =soledadmining.com [OR]
RewriteCond %{SERVER_NAME} =staging.soledadmining.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

I run sudo certbot and 3 entries show up, the two vhosts and the root domain.
When I choose the www (and second, separate command choose staging) I have the option to redirect to HTTPS, I choose 2 for yes/redirect.
Everything redirects to the root domain. and I get a cert error in the browser.
Any thoughts?

1 Like

It seems like the redirect might be intended.
There’s no cert error for me… On soledadmining.com or staging.

The issue you had for www is that you’ll need to get a certificate for both root and www, not one for root and one for www…

Sample command: sudo certbot --apache -d soledadmining.com -d www.soledadmining.com --expand this should expand the certificate for your root domain to cover both root and www

Thank you

1 Like

2 posts were split to a new topic: Can’t access site using cpanel

thanks. I didn’t know I could include two domains in one cert. I ran your command.
The staging site now seems to work (a single H1 tag while I figure this out) as intended but I still get cert errors on www (and still appears to redirect on a different machine that never saw the site).
I appreciate all your help!

Hi,

Your www site is now working correctly in https (I mean, not having certificate error). I believe the redirection is set in certbot’s configuration, which you should find by name of le-options or something similar… Try to output all configuration files and see if there’s such redirection.
apache2ctl -S or apachectl -S

Find your www domain with the above command and locate https configuration, then you can modify the redirection.

Thank you

1 Like

Thank you so much for your expertise! I appreciate your help very much. The site is working perfectly now.

2 Likes

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