Ich habe einen Server mit zwei Websites. Eine davon hat https und die andere nicht. Mein Problem ist, dass ich beim Zugriff auf den Server, der kein https hat, auf den Server umgeleitet werde, der es hat.
Ich verwende Ubuntu 12.04.5 LTS und Apache 2.2. Ich habe versucht, jede Stelle zu finden, an der ich „Rewrite“ verwendet habe, und keine davon hat mir geholfen.
Hier ist die Konfiguration der ersten Website (die https hat)
<VirtualHost *:80>
ServerName www.first_site.com.br
ServerAlias www.first_site.com.br
ServerAdmin info@first_site.com.br
DocumentRoot /var/www/first_site
ErrorLog /var/log/apache2/first_site/error.log
LogLevel warn
CustomLog /var/log/apache2/first_site/access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.first_site.com.br
ServerAlias www.first_site.com.br
ServerAdmin info@first_site.com.br
DocumentRoot /var/www/first_site
ErrorLog /var/log/apache2/first_site/error.log
LogLevel warn
CustomLog /var/log/apache2/first_site/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/wildSSL/STAR_first_site_com_br.crt
SSLCertificateKeyFile /etc/apache2/wildSSL/STAR_first_site_com_br.key
SSLCertificateChainFile /etc/apache2/wildSSL/STAR_first_site_com_br.ca-bundle
SSLProtocol All
</VirtualHost>
</IfModule>
Dies ist die zweite Site-Konfiguration
<VirtualHost *:80>
ServerName www.second_site.com.br
ServerAlias www.second_site.com.br
ServerAdmin info@second_site.com.br
DocumentRoot /var/www/second_site
ErrorLog /var/log/apache2/exati/error.log
LogLevel warn
CustomLog /var/log/apache2/exati/access.log combined
</VirtualHost>
Außerdem erfolgt immer, wenn ich die erste Website ohne https aufrufe, eine automatische Weiterleitung auf die https-Version.
Antwort1
Für die zweite Site hinzufügen
<VirtualHost *:443>
ServerName www.second_site.com.br
ServerAlias www.second_site.com.br
RewriteEngine on
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=permanent]
</VirtualHost>