.htaccess leitet meine Website nicht von HTTP auf HTTPS um

.htaccess leitet meine Website nicht von HTTP auf HTTPS um

Meine .htaccess-Datei leitet meine Domain nicht von HTTP auf HTTPS um. Meine Seiten werden auf HTTPS umgeleitet, aber nicht meine Domain.

Haben Sie eine Idee, was dieses Problem verursachen kann?

RewriteEngine On
RewriteCond %{HTTP_HOST} ^maghreb-secours\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

php_value upload_max_filesize 200M
php_value post_max_size 200M
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Antwort1

Es sieht so aus, als ob etwas Anfragen an Ihren Apex an den Host umleitet wwwund Ihr RewriteCondApex nur so konfiguriert ist, dass es auf dem Apex funktioniert ( ^maghreb-secoursund nicht ^www.maghreb-secours).

$ curl -s --head http://maghreb-secours.com/ | grep -e "^HTTP" -e "^Location:"
HTTP/1.1 301 Moved Permanently
Location: http://www.maghreb-secours.com/
$ curl -s --head https://maghreb-secours.com/ | grep -e "^HTTP" -e "^Location:"
HTTP/1.1 301 Moved Permanently
Location: https://www.maghreb-secours.com/
$ curl -s --head http://www.maghreb-secours.com/ | grep -e "^HTTP" -e "^Location:"
HTTP/1.1 200 OK
$ curl -s --head https://www.maghreb-secours.com/ | grep -e "^HTTP" -e "^Location:"
HTTP/1.1 200 OK

Außerdem bin ich nicht sicher, ob der Backslash erforderlich ist, um den Punkt im Hostnamen zu maskieren.

Vielleicht funktioniert das (einschließlich des Apex, falls sich Ihre Konfiguration später ändert)?

RewriteEngine on
RewriteCond %{HTTPS} != on
RewriteCond %{SERVER_NAME} =www.maghreb-secours.com [OR]
RewriteCond %{SERVER_NAME} =maghreb-secours.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

verwandte Informationen