src/HTTP.php
public static function redirect($url, $status = 307){

		if(!in_array($status, [300, 301, 302, 303, 307])){

			$status = 307;
		}

		$url = trim($url);

		// Append base URL to a relative path

		if(strtolower(substr($url, 0, 4)) != 'http'){

			$base_url = self::detectBaseURL();

			// Unable to detect the base URL

			if(empty($base_url)){

				self::message(500, 'Unable to detect base URL');
				return;
			}

			$url = $base_url . ltrim($url, '/');
		}

		// Check target URL

		$url = self::normaliseURL($url);

		if($url == ''){

			self::message(500, 'Invalid URL provided for redirect operation');
			return;
		}

		// Automatic redirect

		if($status != HTTP::MULTIPLE_CHOICES){

			self::status($status);

			header("Location: $url");
		}

		// Manual redirect

		else{

			self::status(HTTP::MULTIPLE_CHOICES);

			// Prevent the notification page from being cached

			header('Cache-Control: no-cache, must-revalidate');
			header('Expires: Sat, 26 Jul 1997 05:00:00 CEST');
		}

		?>

			<html>
				<head>
					<title>This Page has Moved</title>
				</head>
				<body>
					<h1>This Page has Moved</h1>
					<p>
						The page you have requested has moved to another
						location.
					</p>
					<p>
						If you are not automatically redirected to
						<a href="<?= $url ?>">the page's new location</a>,
						please click <a href="<?= $url ?>">here</a> to do so
						manually.<br>
						If you keep seeing this message, or are otherwise unable
						to reach the new location, please return to
						<a href="/">our homepage</a> and attempt to
						reach the page from there.
					</p>
				</body>
			</html>

		<?php
	}
public static function redirect($url, $status = 307){

		if(!in_array($status, [300, 301, 302, 303, 307])){

			$status = 307;
		}

		$url = trim($url);

		// Append base URL to a relative path

		if(strtolower(substr($url, 0, 4)) != 'http'){

			$base_url = self::detectBaseURL();

			// Unable to detect the base URL

			if(empty($base_url)){

				self::message(500, 'Unable to detect base URL');
				return;
			}

			$url = $base_url . ltrim($url, '/');
		}

		// Check target URL

		$url = self::normaliseURL($url);

		if($url == ''){

			self::message(500, 'Invalid URL provided for redirect operation');
			return;
		}

		// Automatic redirect

		if($status != HTTP::MULTIPLE_CHOICES){

			self::status($status);

			header("Location: $url");
		}

		// Manual redirect

		else{

			self::status(HTTP::MULTIPLE_CHOICES);

			// Prevent the notification page from being cached

			header('Cache-Control: no-cache, must-revalidate');
			header('Expires: Sat, 26 Jul 1997 05:00:00 CEST');
		}

		?>

			<html>
				<head>
					<title>This Page has Moved</title>
				</head>
				<body>
					<h1>This Page has Moved</h1>
					<p>
						The page you have requested has moved to another
						location.
					</p>
					<p>
						If you are not automatically redirected to
						<a href="<?= $url ?>">the page's new location</a>,
						please click <a href="<?= $url ?>">here</a> to do so
						manually.<br>
						If you keep seeing this message, or are otherwise unable
						to reach the new location, please return to
						<a href="/">our homepage</a> and attempt to
						reach the page from there.
					</p>
				</body>
			</html>

		<?php
	}
public static function redirect ( $ url , $ status = 307 ) { if ( ! in_array ( $ status , [ 300 , 301 , 302 , 303 , 307 ] ) ) { $ status = 307 ; } $ url = trim ( $ url ) ; // Append base URL to a relative path if ( strtolower ( substr ( $ url , 0 , 4 ) ) != 'http' ) { $ base_url = self :: detectBaseURL ( ) ; // Unable to detect the base URL if ( empty ( $ base_url ) ) { self :: message ( 500 , 'Unable to detect base URL' ) ; return ; } $ url = $ base_url . ltrim ( $ url , '/' ) ; } // Check target URL $ url = self :: normaliseURL ( $ url ) ; if ( $ url == '' ) { self :: message ( 500 , 'Invalid URL provided for redirect operation' ) ; return ; } // Automatic redirect if ( $ status != HTTP :: MULTIPLE_CHOICES ) { self :: status ( $ status ) ; header ( "Location: $url" ) ; } // Manual redirect else { self :: status ( HTTP :: MULTIPLE_CHOICES ) ; // Prevent the notification page from being cached header ( 'Cache-Control: no-cache, must-revalidate' ) ; header ( 'Expires: Sat, 26 Jul 1997 05:00:00 CEST' ) ; } ?>

			<html>
				<head>
					<title>This Page has Moved</title>
				</head>
				<body>
					<h1>This Page has Moved</h1>
					<p>
						The page you have requested has moved to another
						location.
					</p>
					<p>
						If you are not automatically redirected to
						<a href="<?= $ url ?>">the page's new location</a>,
						please click <a href="<?= $ url ?>">here</a> to do so
						manually.<br>
						If you keep seeing this message, or are otherwise unable
						to reach the new location, please return to
						<a href="/">our homepage</a> and attempt to
						reach the page from there.
					</p>
				</body>
			</html>

		<?php }
Redirect the browser to the provided path.

<p>The provided {@link $url} can be both a relative path, or an absolute
URL. In case the provided path is relative, the current request's base
URL is prepended.<br>
<strong>Note:</strong> This method does not terminate script execution.
Under normal circumstances you will want to terminate execution directly
after calling this method.</p>

<p>The following response codes are supported for the optional parameter
{@link $status}:</p>
<ul>
<li><b>300:</b> Multiple Choices (do not automatically redirect)</li>
<li><b>301:</b> Moved Permanently</li>
<li><b>302:</b> Found (if you want a "temporary redirect" do
<strong>not</strong> use, this status code, send 307 instead!)</li>
<li><b>303:</b> See Other (used to "transform" a POST-request
into a GET-request)</li>
<li><b>307:</b> Temporary Redirect (default, requires HTTP/1.1)</li>
</ul>

@param string $url
@param integer $status
@return void
Redirect the browser to the provided path .