Web

호스팅에 도메인 서로 다른 페이지 이동하기

Zyss 2024. 2. 23. 18:34
반응형

호스팅에 abc.com과 test.com를 연결해 놓는다.
주 도메인은 abc.com 이다.
test.com 으로 접속했을 때 index.html 가 아닌
test.com/test/index.html 으로 접속하고 싶다.
그럴 때 사용하는 방법이다.

 .htaccess 파일을 생성한다.
아래 내용을 넣고 저장한다.

 

방법1

RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.com [NC]
RewriteRule ^(.*)$ https://abc.com/test/ [L,R=301]

 

 

 

방법2

index 파일에 추가

<?php
//echo $_SERVER["HTTP_HOST"];
//return;
if ($_SERVER["HTTP_HOST"]=="test.com") 
{
	header("Location: https://test.com/test/index.html");
	exit();
} 
?>

 

 

방법3
페이지 이동

<?php

header('Location: /test/');
exit();

?>
반응형