Is this the correct URI for header('Location: ') , in particular ./ ?
header('Location: ')
./
header ('HTTP/1.1 301 Moved Permanently'); header ('Location: ./');
Thanks.
You must use an absolute URI according to the specification , so the following should work for you:
// check if the server is secure or not to determine URL prefix if(isset($_SERVER['HTTPS']) and 'on' === $_SERVER['HTTPS']) { $location = 'https://'; } else { $location = 'http://'; } // get the servers base URL $location .= $_SERVER['SERVER_NAME'] . '/'; // grab the current URI without a file name in it $location .= dirname($_SERVER['REQUEST_URI']) . '/'; header('Location: ' . $location); exit();
You can also use:
header('Location: /', false, 301);
I assume that you want to redirect to the "home page", which would be / instead. /