Please tell me how to properly configure vhosts apache . There are three sites in /etc/apache2/sites-enabled/sites

All three are working properly.

When one of them bought an SSL certificate and connected it using a redirect from port 80 to port 443, problems started, namely: Suppose sites: http://site1.com http://site2.com https://site3.com If you enter https://site1.com pens, then the browser reports a non-secure connection and goes to site3.com, but https://site1.com remains in the address bar ....

Redirect code from port 803 to 443

 RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

Redirect code from port 803 to 443

if you have inserted it globally, outside of any virtualhost section, then this is probably not what you need: after all, calls to all sites will now be redirected.

if you had to redirect only one of the sites, then you had to create a new virtualhost with the necessary content:

 <virtualhost *:443> servername site1.com ... </virtualhost> 

and the old lead, for example, to this form:

 <virtualhost *:80> servername site1.com redirect permanent / https://site1.com </virtualhost> 
  • <virtualhost *:80> servername site1.com RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}</virtualhost> now done so - Thekpocobok