internal redirect from cgi (howto)

Alles, was den Apache betrifft, kann hier besprochen werden.

internal redirect from cgi (howto)

Postby balim » 25. June 2023 21:53

Is there a way to redirect (intern) to a file from a cgi-script? The idea is to provide authentification for a file download via a cgi-script, but let the server handle the sending of the file.
Thanks.
balim
 
Posts: 1
Joined: 25. June 2023 21:48
XAMPP version: ?
Operating System: Debian

Re: internal redirect from cgi (howto)

Postby Nobbie » 27. June 2023 11:13

Yes. Modify Location Tag in HTTP Header, apply the target file. In PHP you can use header() function to do this:

Code: Select all
header("Location: http://anydomain/anyfolder/anyfile.php");
exit();


This redirects to the given URL. You should exit() immediately after header(), as there is no use for more content after redirect.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04


Return to Apache

Who is online

Users browsing this forum: No registered users and 109 guests