포워드에 따라 다른 페이지로 자동연결되는 index.php
포워드에 따라 다른 페이지로 자동연결되는 index.php를 만드려는데요..
페이지가 계속 로딩중만되는데 어디가 문제인걸까요?
Copy
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="http://localhost/style.css">
</head>
<?php
//http://test.kr/index.php?forward=A
if ($forward != "A")
//echo("<script>location.replace('./A.html');</script>");
echo("<meta http-equiv='refresh' content='0'; url='./A.html'>");
elseif ($forward != "B")
echo("<script>location.replace('./B.html');</script>");
elseif ($forward != "C")
echo("<script>location.replace('./C.html');</script>");
elseif ($forward != "D")
echo("<script>location.replace('./D/D.html');</script>");
end;
?>
|
답변 5개 / 댓글 2개
일단 if 문법도 이상하네요
":" 이 없는데 endif 아닌 end 를 쓰는것도 이상하고
Copy
$forwardUrl = "";
if ($forward != "A") {
$forwardUrl = "A.html";
} elseif ($forward != "B") {
$forwardUrl = "B.html";
} ...
echo("console.log('".forwardUrl."');</script>");
이렇게 해서 먼저 console 로그 부터 확인한뒤에 고치든지 해보세요
우선 if 문이 이상하네요..
forward=A 라면..
4개의 if 문에 모두 해당되고, 젤 위에 if ($forward != "A") 문을 먼저 실행합니다.
즉, ./A.html 파일로 이동하겠네요.
./A.html 파일에 위에 구문이 동일하게 들어가있다면 무한 반복을 하구요.
그렇지 않다면, 이상없이 이동할 겁니다.
구문을 한번 점검해보세요..
<meta http-equiv='refresh' content='0;url=./A.html'>
답변을 작성하려면 로그인이 필요합니다.