Unintended Re-directs using sub-domains

Hi I am new to web administering and just started to use SSL certificates.

My web server is (include version): Apache/2.4.41 (Ubuntu 20.04)
I am using root shell on my machine.
The version of my client is cerbot 1.16.0

Created a letsencrypt cert successfully for domain.org
I then added subdomains to the main cert using the following
certbot -d domain.org,www.domain.org --expand -v

2 issues that I face

First : when i use https://www.domain.org
it uses the correct document directory assigned in my vhost settings eg /var/www/abc but the url of the browser changes to https://domain.org

What should I do to prevent this re-directing of url ?

Second. i create a vhost for the domain.org and having a different document directory say /var/www/html as a default virtual host. When i use https://www.domain.org it will always redirect me to https://domain.org and the document director /var/www/html

In a non-SSL environment using port 80, I do not face the same set of issues.

Appreciate anyone's help.


Welcome to the Let's Encrypt Community :slightly_smiling_face:

Check the configuration file with the port 80 VirtualHost with ServerName or ServerAlias www.domain.org. You can start with sudo apachectl -S. You might find a redirect (likely added by certbot) that is redirecting to domain.org. If not, visit redirect-checker.org to determine what software is causing the redirect. It could be something like WordPress, for example.


Hi @griffin - thanks for welcoming me. :raised_hands:

I do have a redirect statement in port80 but wonder why that would have been activated when my url is targeted specifically at port 443 using https:// instead of http://

Any suggestions on how I might prevent my sub-domains from pointing to the main domain ?

Thank you


That depends upon what is doing the redirecting. Do you have any RewriteRules in your port 443 VirtualHost or an .htaccess file?


Hi Griffin

I followed up on your comments abt redirections in my port 80 settings.
I had originally thought that these port 80 settings will not affect the port 443 settings.
I cleared up the mess by reducing to just 2 vhost settings.

And voila, the port 443 settings now worked as they should.

Thanks for pointing out.




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