My problem is as follows. I am currently running three virtual hosts, all of which have an SSL certificate. Two out of three virtual hosts are redirecting from HTTP to HTTPS without any issues - e.g. if I type in http://zizek.uk it redirects to https://zizek.uk without any issues. However, for some reason one of the domains does not redirect: http://paradoxoftheday.com directs to main root (i.e. /var/www/html) instead of to its assigned directory (i.e. /var/www/html/paradoxoftheday). [EDIT: this is if you use other browser than Chrome, which automatically prefers HTTPS, e.g. Opera.] All configuration files (in /etc/apache2/sites-available) are set up identically. All .htaccess files are set up identically. And yet, for some reason, zizek.uk does redirect to HTTPS while paradoxoftheday.com does not redirect to HTTPS and instead directs to root directory (which as mentioned is one level higher). Both websites are Wordpress, if that is important.
What do you mean by method? Redirect was arranged by certbot (one of the questions): it added a few lines to the apache config file. All lines looks the same.
|/etc/apache2/sites-available/zizek-le-ssl.conf:|ServerName zizek.uk|
|---|---| <---- This line is not there in the output, not sure why it is showing up here.
|/etc/apache2/sites-available/zizek-le-ssl.conf:|ServerAlias www.zizek.uk|
|/etc/apache2/sites-available/philfaqs-le-ssl.conf:|ServerName philosophyfaqs.com|
|/etc/apache2/sites-available/philfaqs-le-ssl.conf:|ServerAlias www.philosophyfaqs.com|
|/etc/apache2/sites-available/nietzsche.conf:|ServerName aphil.org|
|/etc/apache2/sites-available/nietzsche.conf:|ServerAlias www.aphil.org|
|/etc/apache2/sites-available/potd-le-ssl.conf:|ServerName paradoxoftheday.com|
|/etc/apache2/sites-available/potd-le-ssl.conf:|ServerAlias www.paradoxoftheday.com|
|/etc/apache2/sites-available/zizek.conf:|ServerName zizek.uk|
|/etc/apache2/sites-available/zizek.conf:|ServerAlias www.zizek.uk|
|/etc/apache2/sites-available/quotes.conf:|ServerName paradoxquotes.com|
|/etc/apache2/sites-available/quotes.conf:|ServerAlias www.paradoxquotes.com|
|/etc/apache2/sites-available/classics.conf:|ServerName classics.paradoxoftheday.com|
|/etc/apache2/sites-available/philfaqs.conf:|ServerName philosophyfaqs.com|
|/etc/apache2/sites-available/philfaqs.conf:|ServerAlias www.philosophyfaqs.com|
|/etc/apache2/sites-available/potd.conf:|ServerName paradoxoftheday.com|
|/etc/apache2/sites-available/potd.conf:|ServerAlias www.paradoxoftheday.com|
|/etc/apache2/sites-available/000-default.conf:|# The ServerName directive sets the request scheme, hostname and port that|
|/etc/apache2/sites-available/000-default.conf:|# redirection URLs. In the context of virtual hosts, the ServerName|
|/etc/apache2/sites-available/000-default.conf:|#ServerName www.example.com|
|/etc/apache2/mods-available/info.conf:|# http://servername/server-info (requires that mod_info.c be loaded).|
|/etc/apache2/mods-available/status.conf:|# with the URL of http://servername/server-status|
It seems you have three files that use that same domain: |/etc/apache2/sites-available/potd-le-ssl.conf:|ServerName paradoxoftheday.com| |/etc/apache2/sites-available/quotes.conf:|ServerName paradoxquotes.com| |/etc/apache2/sites-available/potd.conf:|ServerName paradoxoftheday.com|
Now, one is for SSL and one is for HTTP.
That means there is an extra file for HTTP that is unaccounted for and is likely creating the problem.
Thanks to your answer, I did find the culprit. For some reason the ‘default’ configuration was still enabled (I guess I did that early on), and that was the conflicting configuration that redirected me to the root directory. Problem solved!