79564
Goto Top

Htaccess non-www to www und http to https

Hi zusammen

Seit neuerdings kostenlose Zertifikate verfügbar sind, möchte ich auch meine Webseite auf https umleiten lassen.

Aktuell hab ich den zweiten Teil vom Code unten bereits in meiner htaccess stehen.
Geht dies auch ein einem rutsch?
Sonst wird im es im zwei Fällen gleich 2x weitergeleitet, was unnötig ist und auch nicht gerne gesehen wird von Google.

Ziel:
http://example.com > https://www.example.com
http://wwwexample.com > https://www.example.com
https://example.com > https://www.example.com
https://www.example.com > passt so face-smile


RewriteEngine On
RewriteCond %{HTTPS} =off
RewriteRule ^ [https://%]https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L,R=301]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ [http://www.%]http://www.%{HTTP_HOST}/$1 [L,R=301]



Danke
Grüsse Lupita

Content-Key: 290227

Url: https://administrator.de/contentid/290227

Printed on: April 27, 2024 at 04:04 o'clock

Member: fognet
fognet Dec 06, 2015 at 11:10:31 (UTC)
Goto Top
Hi

Ich habe einfach im Virtual host beim http Teil dies ergänzt:
> Redirect permanent / https://meineseite.ch/

Funktioniert Perfekt.
LG PPR
Member: StefanKittel
StefanKittel Dec 06, 2015 at 11:30:31 (UTC)
Goto Top
Hallo,

probier mal

RewriteEngine On

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|

RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Es sind mehrere Conditions zusammen.

Viele Grüße

Stefan
Mitglied: 79564
79564 Dec 07, 2015 at 10:49:13 (UTC)
Goto Top
Zitat von @fognet:

Hi

Ich habe einfach im Virtual host beim http Teil dies ergänzt:
> Redirect permanent / https://meineseite.ch/

Funktioniert Perfekt.
LG PPR

Hab in diesem Fall leider kein Zugriff auf den Virtual Host File.
Mitglied: 79564
79564 Dec 07, 2015 at 10:49:45 (UTC)
Goto Top
Zitat von @StefanKittel:

Hallo,

probier mal

RewriteEngine On

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|

RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Es sind mehrere Conditions zusammen.

Viele Grüße

Stefan

Hi Stefan
Da wechselt er nicht automatisch auf https... komisch.