2016-07-08 1 views
0

SSL을 사용하여 단일 페이지 mysubdir/checkout.php을 보호하고 싶습니다. 예 : https://www.mywebsite.com/fr/checkout, 여기서 fr은 언어 코드입니다.URL 재 작성 - 한 페이지를 제외하고 HTTP로 리디렉션

다른 모든 페이지는 http로 다시 리디렉션되어야합니다.

이것은 .htaccess에 있지만 작동하지 않습니다. I 입력하지만 때

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

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

##### Checkout ##### 
RewriteRule ^/(fr|en)/checkout/?$ mysubdir/checkout.php?lang=$1 [QSA] 

는 : https://www.mywebsite.com/fr/checkouthttps://www.mywebsite.com/mysubdir/checkout.php?lang=fr로 리디렉션. 왜?

이 문제에 대한 해결책은 무엇입니까?

답변

0

시도 :

RewriteEngine on 
#redirect checkout.php from http to https 
RewriteCond %{HTTPS} off 
RewriteRule checkout\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R] 
#redirect all requests except "checkout.php" from https to http 
RewriteCond %{HTTPS} on 
RewriteRule !checkout\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R] 

이는 /checkout.php HTTPS로 리디렉션됩니다.

+0

내 경우에는 checkout.php도/fr/checkout에 다시 작성됩니다. – sc1013

+0

정확히 무엇이 문제입니까? 다른 규칙이나 htaccess가 있습니까? – starkeen

0

REQUEST_URI 대신 변수 REQUEST_URI을 사용해야하므로 변수를 으로 사용해야합니다.

RewriteEngine On 

RewriteCond %{HTTPS} on 
RewriteCond %{THE_REQUEST} !/fr/checkout 
RewriteRule^http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE] 

RewriteCond %{HTTPS} off 
RewriteCond %{THE_REQUEST} /fr/checkout 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE] 

##### Checkout ##### 
RewriteRule ^/?(fr|en)/checkout/?$ mysubdir/checkout.php?lang=$1 [QSA,L,NC] 

테스트시 브라우저 캐시를 지우십시오.