2017-12-21 38 views
1

Strict-Transport-Security 헤더를 웹 루트의 .htaccess 파일에 추가하려고합니다. 그것을 추가하고 내 웹 사이트를 다시로드 한 후에는 응답 헤더에서 볼 수 없습니다. 기록을 위해, 내 재 작성이 효과가있다. 헤더가 왜 .. 아닌지 잘 모르겠습니다. 문제가되는 경우 GoDaddy를 통해 VPS를 사용하고 있습니다. 내가 뭔가 잘못하고 있는거야?.htaccess의 Strict-Transport-Security Header가 작동하지 않는 이유는 무엇입니까?

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS 

RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L] 

# php -- BEGIN cPanel-generated handler, do not edit 
# Set the “ea-php70” package as the default “PHP” programming language. 
<IfModule mime_module> 
    AddType application/x-httpd-ea-php70 .php .php7 .phtml 
</IfModule> 
# php -- END cPanel-generated handler, do not edit 
Options -Indexes 
+0

여기 내 htaccess로입니다. VPS 때문일 가능성이 큽니다. 'http : // example.com'은'https'로 리디렉션됩니까? – anubhava

+0

예, 리디렉션이 작동합니다. 그것은 작동하지 않는 헤더 인 것 같습니다. 이 헤더뿐만 아니라 다른 보안 헤더도 시도했지만 둘 중 하나도 작동하지 않습니다. – user3614030

답변

0

시도가 expressions을 사용 :이 내 아파치 2.4에 잘 작동

Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" "expr=%{HTTPS} == 'on'"