← 전체로 돌아가기
스킬 network

HTTPS 강제 리다이렉트

HTTP 트래픽 HTTPS로 301 리다이렉트 시킴

httpsredirecthtaccessapachessl

HTTPS 강제 리다이렉트 (.htaccess)

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

.htaccess 파일에 위 내용 추가. HTTP 요청 들어오면 HTTPS로 301 리다이렉트 시킴. SSL 설치 후 적용 확인 필요.

여기서 배울 것

  1. .htaccess 파일로 HTTP -> HTTPS 강제 전환 가능.
  2. RewriteEngine On으로 리라이트 모듈 활성화.
  3. RewriteCond %{HTTPS} off 조건으로 HTTPS 아닐 때만 적용.
  4. [L,R=301] 플래그로 영구 리다이렉트 처리.
원본 파일 보기 (.claude/skills/tn-force-https-htaccess/SKILL.md)
---
name: HTTPS 강제 리다이렉트 (.htaccess)
description: This skill should be used when the user asks to force HTTP traffic to HTTPS using an .htaccess file, or when they need to implement a 301 redirect for HTTPS on an Apache server after SSL installation.
version: 1.0.0
source: /home/son/prj/resume/backup_notes_260317/notion/Tech Note/https , htcaccess b2dcd58aacf24aad9bb53d1a8fe1f468.md
---

# https , htcaccess

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

.htcaccess

after install ssl, check it.