PHP 리디렉션

PHP는 페이지에서 URL로 리디렉션합니다.PHP 301 리디렉션.

이 PHP 리디렉션은 HTTP 응답 상태 코드: 301 Moved Permanently를 반환해야 합니다.

검색 엔진은 301 응답 상태 코드를 사용하여 이전 URL에서 새 URL로 페이지 순위를 전송합니다.

PHP 헤더 리디렉션

old-page.php 코드를 new-page.php로의 리디렉션 코드로 바꿉니다.

이전 페이지.php:

<?php
// PHP permanent URL redirection
header("Location: http://www.domain.com/new-page.php", true, 301);
exit();
?>

이전 페이지에는 .php 파일 확장자가 있어야 합니다.

새 페이지는 모든 확장자를 포함할 수 있습니다.

PHP 리디렉션 예

예 #1

php-리디렉션-테스트.php

<?php
// PHP permanent URL redirection test
header("Location: https://cmtoinchesconvert.com/ko/web/dev/php-redirect.html", true, 301);
exit();
?>

 

이 링크를 눌러 php-redirect-test.php에서 이 페이지로 다시 리디렉션하십시오.

 

PHP 리디렉션 테스트 - PHP 파일

예 #2

php-redirect-test.htm

<?php
// PHP permanent URL redirection test
header("Location: https://cmtoinchesconvert.com/ko/web/dev/php-redirect.html", true, 301);
exit();
?>

 

html 파일 php-redirect-test.htm에서 PHP 리디렉션은 일반적으로 .htaccess 또는 httpd.conf 파일에서 활성화되지 않는 한 .html 파일 확장자 때문에 작동하지 않습니다.

 

PHP 리디렉션 테스트 - HTML 파일

 

HTML 파일에서 PHP를 활성화하려면 다음 코드를 .htaccess 또는 httpd.conf 파일 에 추가하십시오.

Addtype application/x-httpd-php .htm .html

 

URL 리디렉션 ►

 


또한보십시오

Advertising

웹 개발
°• CmtoInchesConvert.com •°