Pengalihan PHP

PHP redirect dari halaman ke URL. Pengalihan PHP 301.

Pengalihan PHP ini harus mengembalikan kode status respons HTTP: 301 Dipindahkan Secara Permanen.

Mesin pencari menggunakan kode status respons 301 untuk mentransfer peringkat halaman dari URL lama ke URL baru.

Pengalihan tajuk PHP

Ganti kode old-page.php dengan kode redirection ke new-page.php.

halaman-lama.php:

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

Halaman lama harus memiliki ekstensi file .php.

Halaman baru bisa dengan ekstensi apa saja.

Contoh pengalihan PHP

Contoh 1

php-redirect-test.php

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

 

Tekan tautan ini untuk mengalihkan dari php-redirect-test.php kembali ke halaman ini:

 

Tes pengalihan PHP - file PHP

Contoh #2

php-redirect-test.htm

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

 

Pengalihan PHP dari file html php-redirect-test.htm biasanya tidak akan berfungsi karena ekstensi file .html, kecuali diaktifkan di file .htaccess atau httpd.conf:

 

Tes pengalihan PHP - file HTML

 

Untuk mengaktifkan PHP dalam file HTML, tambahkan kode ini ke file .htaccess atau httpd.conf:

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

 

Pengalihan URL ►

 


Lihat juga

Advertising

PENGEMBANGAN WEB
°• CmtoInchesConvert.com •°