프로덕션 환경에서 HTTPS를 강제하는 규칙을 통합하려고 시도한 후에이 오류가 발생하기 시작했습니다. BWC_ENV 환경 변수가 다른 값의 소수 가질 수 등 "자극", "무대", "ben_local", "nam_local"여기강제 HTTPS 규칙을 추가 할 때 .htaccess 리다이렉트 루프 (Amazon Elastic Beanstalk)
나의 htaccess로이다 :
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:BWC_ENV} ^prod$
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Parse the subdomain as a variable we can access in our scripts
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^www
RewriteCond %{HTTP_HOST} ^([^\.]+)\.([^\.]+)\.([^\.]+)$
RewriteRule ^(.*)$ /$1?subdomain=%1
# Ditto for the path; map all requests to /index.php
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !robots.txt
RewriteRule ^(.*)$ /index.php?path=$1 [L,QSA]
# robots.txt - supply the correct one for each environment
RewriteRule ^robots.txt$ /robots.prod.txt [NC]
RewriteCond %{ENV:BWC_ENV} !prod
RewriteRule ^robots.prod.txt$ /robots.stage.txt [NC]
편집
내 .htaccess에만 다음 내용 만 포함되어 있으면 리디렉션 루프도 발생합니다. 왜 이럴 수 있니?
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
큰 도움이되었습니다. –
정말 고마워요! 나는 [NearlyFreeSpeech] (https://www.nearlyfreespeech.net/)에서 호스팅되는 사이트를 가지고 있으며, 이것을 작동시키기 위해서'X-Forwarded-Proto '를 사용해야했습니다. 또한'RewriteCond % {HTTPS}! = on'으로 리다이렉트 루프를 만들었습니다. –
@RocketHazmat 잘 알고 있고, 기꺼이 도와 줬습니다! –