Linux : Apache : HTTP를 HTTPS로 리디렉션 방법, 예제, 명령어 > LINUX

본문 바로가기
사이트 내 전체검색

LINUX

Linux : Apache : HTTP를 HTTPS로 리디렉션 방법, 예제, 명령어

페이지 정보

profile_image
작성자 최고관리자
댓글 0건 조회 1,890회 작성일 24-05-16 16:31

본문

https://jjeongil.tistory.com/2468 


####################################### 

VirtualHost 이용 수정 후 httpd restart


<VirtualHost *:80> 

  ServerName example.com

  ServerAlias www.example.com


  Redirect permanent / https://example.com/

</VirtualHost>


<VirtualHost *:443>

  ServerName example.com

  ServerAlias www.example.com


  Protocols h2 http/1.1


  # SSL Configuration


  # Other Apache Configuration


</VirtualHost>



---------------------

일반적으로 사이트의 HTTPS www 버전을 non-ww로 리디렉션하거나 그 반대의 경우도 마찬가지입니다. 다음은 구성 예입니다:


<VirtualHost *:80> 

  ServerName example.com

  ServerAlias www.example.com


  Redirect permanent / https://example.com/

</VirtualHost>


<VirtualHost *:443>

  ServerName example.com

  ServerAlias www.example.com


  Protocols h2 http/1.1


  <If "%{HTTP_HOST} == 'www.example.com'">

    Redirect permanent / https://example.com/

  </If>


  # SSL Configuration


  # Other Apache Configuration


</VirtualHost>



#######################################

.htaccess를 사용하여 HTTP를 HTTPS로 리디렉션



RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]


------------------------------------------------------

아래 예는 www로 요청이 시작되는지 확인하는 추가 조건이 있습니다. 모든 방문자가 HTTPS non-www 버전의 사이트를 사용하도록 강제하려면 이를 사용합니다:


RewriteCond %{HTTPS} off [OR]

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]

RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]




댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

  • 게시물이 없습니다.

접속자집계

오늘
2,087
어제
4,039
최대
6,642
전체
830,602
contact : webmaster@beautipia.co.kr
Copyright © beautipia.co.kr. All rights reserved.