PHP-omleiding

PHP redirect van pagina naar URL.PHP 301-omleiding.

Deze PHP-omleiding zou HTTP-antwoordstatuscode moeten retourneren: 301 Permanent verplaatst.

Zoekmachines gebruiken de 301-responsstatuscode om de pagerank over te dragen van de oude URL naar de nieuwe URL.

PHP-header omleiding

Vervang oude-pagina.php-code door omleidingscode naar nieuwe-pagina.php.

oude-pagina.php:

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

De oude pagina moet de bestandsextensie .php hebben.

De nieuwe pagina kan elke extensie hebben.

Voorbeelden van PHP-omleidingen

Voorbeeld 1

php-redirect-test.php

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

 

Druk op deze link om van php-redirect-test.php terug te gaan naar deze pagina:

 

PHP-omleidingstest - PHP-bestand

Voorbeeld #2

php-redirect-test.htm

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

 

PHP-omleiding vanuit het html-bestand php-redirect-test.htm werkt meestal niet vanwege de .html-bestandsextensie, tenzij dit is ingeschakeld in het .htaccess- of httpd.conf-bestand:

 

PHP-omleidingstest - HTML-bestand

 

Om PHP in HTML-bestanden in te schakelen, voegt u deze code toe aan het .htaccess- of httpd.conf-bestand:

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

 

URL-omleiding ►

 


Zie ook

Advertising

WEBONTWIKKELING
°• CmtoInchesConvert.com •°