PHP peradresavimas

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.

PHP antraštės peradresavimas

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 peradresavimo pavyzdžiai

1 pavyzdys

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

2 pavyzdys

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

 

URL peradresavimas ►

 


Taip pat žr

Advertising

INTERNETO KŪRIMAS
°• CmtoInchesConvert.com •°