php USES header to implement 301 jump code instances
- 2020-11-25 07:12:02
- OfStack
Small code for PHP 301 jump
<?php
$the_host = $_SERVER['HTTP_HOST'];
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
if($the_host !== 'www.ofstack.com')
{
//echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://www.ofstack.com' . $_SERVER['PHP_SELF'] . $request_uri);
}
?>