2013-02-21 3 views
0

이 URL은 http://www.mysite.com/checkout/payment입니다.이 페이지를 리디렉션 할 파일을 만들었습니다. URL이 '결제/지불'과 다른 경우 URL은 일반적인 http로 바뀝니다.HTACCESS를 사용하여 특정 페이지를 HTTPS로 리디렉션

하지만 문제가 발생해도 애셋 (JS, CSS, JPG, PNG)은 항상 일반 HTTP로 리디렉션됩니다. 어떻게 수정합니까?

RewriteCond %{HTTPS} on 
RewriteCond %{REQUEST_URI} !(checkout/pay) 
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] 

RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} (checkout/pay) 
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] 
+0

가 나는 그들이 다음''을 사용''대신 예를 들어 상대 URL을 사용할 수 있도록 더 나은 이러한 리소스의 URL을 변경할 생각합니다. 물론 적절한 프로토콜 (http/https)을 주입하십시오. – kjetilh

답변

0

다음과 같은 규칙을 시도하십시오 :

# Redirect checkout pay(ment) pages to https 
RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} ^/checkout/pay [NC] 
RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] 

# Redirects all resources where the http referer field matches the checkout payment page. 
# Weirdly enough I can't seem to use any server variables in the http referer regex. Please change it to match your host. 
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_REFERER} ^https://www.mysite.com/checkout/pay [NC] 
RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] 
관련 문제