PHP 301 redirect location URI format?

You must use an absolute URI according to the spec so something like the following should work for you.

You must use an absolute URI according to the spec so something like 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 = ''; } // 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().

Thank you, Treffynnon. – Francisc Apr 21 at 10:03.

You can also use: header('Location: /', false, 301); I assume you want to redirect to the 'homepage', that'd be / instead of .

I want to redirect to the root of the folder where the file that contains that code resides. In this particular case it is the root of the site as well. I'm worried because I read HTTP/1.1 requires absolute path.

– Francisc Apr 21 at 9:35 1 According to the standard, an absolute URL is required. This will work, but is not valid – Pekka Apr 21 at 9:36 1 As @Pekka mentioned see w3. Org/Protocols/rfc2616/rfc2616-sec14.

Html#sec14.30 – Treffynnon Apr 21 at 9:38 I see. So is there a real risk by using . / or /?

– Francisc Apr 21 at 9:41 Thanks for the comments, didn't know an absolute url was required. Upvoted the correct solution. – Wesley van Opdorp Apr 21 at 9:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions