
내 .htaccess 파일이 내 도메인을 HTTP에서 HTTPS로 리디렉션하지 않습니다. 내 페이지가 HTTPS로 리디렉션되지만 내 도메인은 리디렉션되지 않습니다.
이 문제의 원인이 무엇인지 아시나요?
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
답변1
무언가가 apex에 대한 요청을 호스트로 리디렉션하고 있는 것 같습니다 www
. RewriteCond
apex( ^maghreb-secours
가 아닌 ^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
또한 호스트 이름에서 점을 이스케이프하려면 백슬래시가 필요한지 잘 모르겠습니다.
아마도 이것이 작동할 것입니까(구성이 차후에 변경되는 경우의 정점 포함)?
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]