PHP novirzīšana no lapas uz URL.PHP 301 novirzīšana.
Šai PHP novirzīšanai ir jāatgriež HTTP atbildes statusa kods: 301 Moved Permanently.
Meklētājprogrammas izmanto atbildes statusa kodu 301, lai pārsūtītu lapas rangu no vecā URL uz jauno URL.
Aizstāt old-page.php kodu ar novirzīšanas kodu uz new-page.php.
old-page.php:
<?php
// PHP permanent URL redirection
header("Location: http://www.domain.com/new-page.php", true,
301);
exit();
?>
Vecajai lapai ir jābūt .php faila paplašinājumam.
Jaunā lapa var būt ar jebkuru paplašinājumu.
php-redirect-test.php
<?php
// PHP permanent URL redirection test
header("Location:
https://cmtoinchesconvert.com/lv/web/dev/php-redirect.html", true, 301);
exit();
?>
Nospiediet šo saiti, lai novirzītu no php-redirect-test.php atpakaļ uz šo lapu:
PHP novirzīšanas tests - PHP fails
php-redirect-test.htm
<?php
// PHP permanent URL redirection test
header("Location:
https://cmtoinchesconvert.com/lv/web/dev/php-redirect.html", true, 301);
exit();
?>
PHP novirzīšana no html faila php-redirect-test.htm parasti nedarbosies .html faila paplašinājuma dēļ, ja vien tas nav iespējots failā .htaccess vai httpd.conf:
PHP novirzīšanas tests - HTML fails
Lai iespējotu PHP HTML failos, pievienojiet šo kodu .htaccess vai httpd.conf failam:
Addtype application/x-httpd-php .htm .html
Advertising