티스토리 뷰

반응형

javascript, java  http > https 리다이렉트 방법!!

 

javascript

<script type="text/javascript">

if (document.location.protocol == 'http:') {

    document.location.href = document.location.href.replace('http:', 'https:');

}

</script>

 

java 

String url = request.getRequestURL().toString();

if(url.startsWith("http://") && url.indexOf("localhost") < 0) {
    url = url.replaceAll("http://", "https://");
    response.sendRedirect(url);
}
or
url = String.format("http://%s", request.getServerName());
 
 
끘~!

 

반응형