$url = 'http://' . $_SERVER['HTTP_HOST']; // Get the server$url .= rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); // Get the current directory$url .= '/your-relative/path-goes/here/'; // <-- Your relative pathheader('Location: ' . $url, true, 302); // Use either 301 or 302
<?php
// page.php
require “function.php”
// Redirects to www.example.com/index.php if the// user isn’t authentication level 5authRedirect($_SESSION[‘u_auth’], 5);
// Redirects to www.example.com/index.php if the// user isn’t authentication level 4authRedirect($_SESSION[‘u_auth’], 4);
// Redirects to www.someotherplace.com/somepage.php if the// user isn’t authentication level 2authRedirect($_SESSION[‘u_auth’], 2, “www.someotherplace.com/somepage.php”);
. . .