링크
https://sir.kr/qa/326353 (107) https://duotone.co.kr/entry/PHP-접속주소를-HTTP에서-HTTPS로-강제-포워딩하기 (147)<!--ip 리다이렉션-->
<?php
$full_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
// https 도메인 redirect 하기
if (stripos($full_url, "https://아이피") !== false) {
goto_url("https://도메인r" . $_SERVER['REQUEST_URI']);
}
// http 도메인 redirect 하기
if (stripos($full_url, "http://아이피") !== false) {
goto_url("https://도메인" . $_SERVER['REQUEST_URI']);
}
// 참고, 위 둘을 한꺼번에 처리하기
if (stripos($full_url, "//아이피") !== false) {
goto_url("https://도메인" . $_SERVER['REQUEST_URI']);
}
?>
<!--끝-->
<!--http를 https로 강제 리다이렉트-->
<?php
//If the HTTPS is not found to be "on"
if(!isset($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != "on")
{
//Tell the browser to redirect to the HTTPS URL.
header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"], true, 301);
//Prevent the rest of the script from executing.
exit;
}
?>
<!--끝-->
출처
ip)
https://sir.kr/qa/326353
https)
https://duotone.co.kr/entry/PHP-접속주소를-HTTP에서-HTTPS로-강제-포워딩하기
.htaccess파일을 쓰면 되는데 제가 서버를 잘못 건드렸는지 rewrite module이 활성화가 안되서 php에서 사용할 수 있는 방법을 찾아보았습니다.
head.sub.php 상단에 올려서 사용하고 있어요.
게시글 목록
| 번호 | 제목 |
|---|---|
| 20497 | |
| 20496 | |
| 20467 | |
| 20455 | |
| 20448 | |
| 20447 | |
| 20446 | |
| 20428 | |
| 20424 | |
| 20421 | |
| 20404 | |
| 20402 | |
| 20401 | |
| 20389 | |
| 20350 | |
| 20345 | |
| 20333 | |
| 20307 | |
| 20286 | |
| 20284 | |
| 20281 | |
| 20280 | |
| 20239 | |
| 20235 | |
| 20226 | |
| 20197 | |
| 20192 | |
| 20189 | |
| 20166 | |
| 20147 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기