http -> https (rewrite urls)

modssl사이트에있는 faq에 좋은내용이 있어서 퍼옵니다.
http로 연결한뒤 특정 페이지를 https로 rewrite하는 아파치설정내용입니다.
제가 써먹을려고 적어두었다가 아주 유용한듯해서 올립니다.

Question ==>>
How can I use relative hyperlinks to switch between HTTP and HTTPS?
Usually you have to use fully-qualified hyperlinks because you have to change the URL scheme. But with the help of some URL manipulations through mod_rewrite you can achieve the same effect while you still can use relative URLs:

RewriteEngine on
RewriteRule ^/(.*):SSL$ https://%{SERVER_NAME}/$1 [R,L] 
RewriteRule ^/(.*):NOSSL$ http://%{SERVER_NAME}/$1 [R,L]

This rewrite ruleset lets you use hyperlinks of the form

<a href="./document.html:SSL">

관련 링크: http://www.modssl.org/docs/2.8/ssl_faq.html

+ Recent posts