Redirect issues

I read a lot about this issue, even on this place, but I can't figure out why it's not working.

Issue:
I can't redirect my domain. What I want is a redirect to https://www.rossotono.it.
This is the current situation:

so, basically, it works with www and it does not work with non-www.

Moreover, if I go to www.rossotono.it/franchising directly, it returns a 404. While if I go to www.rossotono.it/franchising clicking from a link in the website it works.

Here there are my confs:

rossotono.it.conf

<VirtualHost *:80> 
   ServerName www.rossotono.it
   Redirect permanent / https://www.rossotono.it
   DocumentRoot /var/www/rossotono.it/public_html
   ErrorLog /var/log/httpd/rossotono_it_error.log
   CustomLog /var/log/httpd/rossotono_it_requests.log combined
   <Directory "/var/www/rossotono.it/public_html" >
      AllowOverride All
   </Directory>
   RewriteEngine On
   RewriteCond %{HTTP:X-Forwarded-Proto} !=https
   RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]
</VirtualHost>
<VirtualHost *:80>
   ServerName rossotono.it
   RedirectMatch permanent ^/?(.*) https://www.rossotono.it/$1
</VirtualHost>

rossotono.it-le-ssl.conf

 <IfModule mod_ssl.c>
    <VirtualHost *:443>
       ServerName www.rossotono.it
       ServerAlias rossotono.it
       DocumentRoot /var/www/rossotono.it/public_html
       ErrorLog /var/log/httpd/rossotono_it_error.log
       CustomLog /var/log/httpd/rossotono_it_requests.log combined
       <Directory "/var/www/rossotono.it/public_html" >
          AllowOverride All
       </Directory>
       SSLCertificateFile /etc/letsencrypt/live/rossotono.it/cert.pem
       SSLCertificateKeyFile /etc/letsencrypt/live/rossotono.it/privkey.pem
       Include /etc/letsencrypt/options-ssl-apache.conf
       SSLCertificateChainFile /etc/letsencrypt/live/rossotono.it/chain.pem
    </VirtualHost>
 </IfModule>

What I tried:

  • flushdns on my pc
  • connecting on website from another pc using another connection

Thanks to those who are gonna help me.

Hello @Tutancagamon,

Below conf should work fine:

rossotono.it.conf

<VirtualHost *:80> 
   ServerName www.rossotono.it
   ServerAlias rossotono.it
   ErrorLog /var/log/httpd/rossotono_it_error.log
   CustomLog /var/log/httpd/rossotono_it_requests.log combined
   Redirect permanent / https://www.rossotono.it/
</VirtualHost>

rossotono.it-le-ssl.conf

<IfModule mod_ssl.c>
   <VirtualHost *:443>
      ServerName rossotono.it
      ErrorLog /var/log/httpd/rossotono_it_error.log
      CustomLog /var/log/httpd/rossotono_it_requests.log combined
      Include /etc/letsencrypt/options-ssl-apache.conf
      SSLCertificateFile /etc/letsencrypt/live/rossotono.it/cert.pem
      SSLCertificateKeyFile /etc/letsencrypt/live/rossotono.it/privkey.pem
      SSLCertificateChainFile /etc/letsencrypt/live/rossotono.it/chain.pem
      Redirect permanent / https://www.rossotono.it/
   </VirtualHost>
   
   <VirtualHost *:443>
      ServerName www.rossotono.it
      DocumentRoot /var/www/rossotono.it/public_html
      ErrorLog /var/log/httpd/rossotono_it_error.log
      CustomLog /var/log/httpd/rossotono_it_requests.log combined
      <Directory "/var/www/rossotono.it/public_html" >
         AllowOverride All
      </Directory>
      Include /etc/letsencrypt/options-ssl-apache.conf
      SSLCertificateFile /etc/letsencrypt/live/rossotono.it/cert.pem
      SSLCertificateKeyFile /etc/letsencrypt/live/rossotono.it/privkey.pem
      SSLCertificateChainFile /etc/letsencrypt/live/rossotono.it/chain.pem
   </VirtualHost>
</IfModule> 

I hope it helps.

Cheers,
sahsanu

1 Like

Thank you. I edited the confs.
For now it not works but I think the edits have not taken effect yet, I’ll wait the refresh of the nameserver.

Ok, solved, thanks @sahsanu. Now it returns the ERR_CERT_AUTHORITY_INVALID error when I point to rossotono.it

Hi @Tutancagamon,

Your Apache is serving a self signed certificate for rossotono.it so it is not loading the right conf or you have several conf files for rossotono.it. You should try to find the bad one and remove it, after that you need to restart or reload Apache.

Cheers,
sahsanu

Hi @Tutancagamon,

Just for the records, I've checked it again and seems you have solved your certificate error issue with rossotono.it and all redirections are working properly so I'm glad you get it up and running ;).

Have a nice day.
sahsanu

1 Like

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