PHP peradresavimas iš puslapio į URL.PHP 301 peradresavimas.
Šis PHP peradresavimas turėtų grąžinti HTTP atsako būsenos kodą: 301 Perkeltas visam laikui.
Paieškos sistemos naudoja 301 atsakymo būsenos kodą, kad perkeltų puslapio reitingą iš senojo URL į naują URL.
Pakeiskite old-page.php kodą peradresavimo kodu į new-page.php.
old-page.php:
<?php
// PHP permanent URL redirection
header("Location: http://www.domain.com/new-page.php", true,
301);
exit();
?>
Senas puslapis turi turėti .php failo plėtinį.
Naujas puslapis gali būti su bet kokiu plėtiniu.
php-redirect-test.php
<?php
// PHP permanent URL redirection test
header("Location:
https://cmtoinchesconvert.com/lt/web/dev/php-redirect.html", true, 301);
exit();
?>
Paspauskite šią nuorodą, kad peradresuotumėte iš php-redirect-test.php atgal į šį puslapį:
PHP peradresavimo testas – PHP failas
php-redirect-test.htm
<?php
// PHP permanent URL redirection test
header("Location:
https://cmtoinchesconvert.com/lt/web/dev/php-redirect.html", true, 301);
exit();
?>
PHP peradresavimas iš html failo php-redirect-test.htm paprastai neveiks dėl .html failo plėtinio, nebent jis įjungtas .htaccess arba httpd.conf faile:
PHP peradresavimo testas – HTML failas
Norėdami įjungti PHP HTML failuose, pridėkite šį kodą prie .htaccess arba httpd.conf failo:
Addtype application/x-httpd-php .htm .html
Advertising