No redirect to https

Hello, I have installed the SSL certificate with certbot. The installation was successful.
This is the website https://www.geomotion.it
I use time4vps servers
The problem is that by typing only www.geomotion.it or geomotion.it the site is directed to http and not https. How can I solve this problem? I also tried to uninstall and reinstall the certificate, but nothing has changed.
I use ubuntu server 20.04 and cerbot 1.32.0

Hi @elsalbaneo, and welcome to the LE community forum :slight_smile:

Please show the output of:
apachectl -t -D DUMP_VHOSTS

2 Likes

Thanks rg905.
That is the result:

root@www:/# apachectl -t -D DUMP_VHOSTS
VirtualHost configuration:
*:443  www.geomotion.it (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
*:80   www.geomotion.it (/etc/apache2/sites-enabled/000-default.conf:1)

Please show file:
/etc/apache2/sites-enabled/000-default.conf

3 Likes

I'm alsonot seeing an alias for geomotion.it? That might have confused Certbot when generating the redirect directives.

3 Likes

That is the file: /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>
        ServerName www.geomotion.it
        ServerAlias https://www.geomotion.it
        ServerAdmin filippo@geomotion.info
        DocumentRoot /var/www/lizmap/lizmap-web-client/lizmap/www/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        Alias /lizmap/ /var/www/lizmap/

                FcgidIOTimeout 120
        <Directory "/var/www/lizmap/lizmap-web-client/lizmap/">
    Options -Indexes +FollowSymLinks +ExecCGI
    AllowOverride All
    Require all granted
   </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin/">
      AllowOverride All
      Options +ExecCGI -MultiViews +FollowSymLinks
      AddHandler fcgid-script .fcgi
      Require all granted
    </Directory>


RewriteEngine on
RewriteCond %{SERVER_NAME} =mlal.geoatamai.it [OR]
RewriteCond %{SERVER_NAME} =www.mlal.geoatamai.it
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

That should be:

        ServerName www.geomotion.it
        ServerAlias geomotion.it

That should be:

RewriteCond %{SERVER_NAME} =geomotion.it [OR]
RewriteCond %{SERVER_NAME} =www.geomotion.it

OR just:

5 Likes

it works! Thanks a lot!

3 Likes

I'm sorry, but I have an other question. If I want to use a subdomain like geoportale.geomotion.it, how do I change configuration file?

Which configuration file?
And to do what?

2 Likes
<VirtualHost *:80>
	ServerName geoportale.geomotion.it
	ServerAlias geoportale.geomotion.it
	ServerAdmin filippo@geomotion.info
        DocumentRoot /var/www/lizmap/lizmap-web-client/lizmap/www/
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
	Alias /lizmap/ /var/www/lizmap/

		FcgidIOTimeout 120
	<Directory "/var/www/lizmap/lizmap-web-client/lizmap/">
    Options -Indexes +FollowSymLinks +ExecCGI
    AllowOverride All
    Require all granted
   </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin/">
      AllowOverride All
      Options +ExecCGI -MultiViews +FollowSymLinks
      AddHandler fcgid-script .fcgi
      Require all granted
    </Directory>


RewriteEngine on
RewriteCond %{SERVER_NAME} =mlal.geoatamai.it [OR]
RewriteCond %{SERVER_NAME} =www.mlal.geoatamai.it
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

That is the configuration file. I would like to have SSL certificate for the subdomain geoportale.geomotion.it

It depends on if that name is supposed to host its' own content or not.
If so, then you would need to create another vhost that serves that name and points to the appropriate DocumentRoot.
If not, then you only need to add that name as an ServerAlias to that vhost.

Then you will need to obtain a certificate.

Then you can use that certificate in the corresponding secured vhost.

3 Likes

This is not the correct Community for generic "How do I configure my Apache" questions I'm afraid. It seems you've just copy/pasted a previous virtualhost and only changed the ServerName and ServerAlias directives, without modifying the other relevant directives accordingly.

But as I said, this is not the correct place to receive help on generic Apache configuration issues that are not related to HTTPS/SSL/TLS/Let's Encrypt. We're mostly volunteers here with finite time/effort which we'd like to concentrate on HTTPS/SSL/TLS/Let's Encrypt issues. If we'd also start providing generic Apache configuration assistance, that, IMO, wouldn't be the right allocation of volunteer time and effort.

5 Likes

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