php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #13991 prepending protocol and hostname to location: headers
Submitted: 2001-11-08 11:40 UTC Modified: 2001-11-08 12:59 UTC
From: mitja at doticni dot net Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.6 OS: any
Private report: No CVE-ID: None
 [2001-11-08 11:40 UTC] mitja at doticni dot net
Would it be possible that when issuing header("Location: ...") the protocol and host name would automagically be prepended, if it was missing. Since it's handled specially anyway, it perhaps wouldn't be such a problem?

So

header("Location: /index.html")

would be the same as

global $HTTP_HOST, $HTTPS;
if ($HTTPS=="on")
    header("Location: https://$HTTP_HOST/index.html");
else
    header("Location: http://$HTTP_HOST/index.html");

(in apache anyway)

It would mean less typing for the programmer, forced compliance with HTTP/1.1 and it would work for both http:// and https:// which now have to be handled separately.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-08 12:59 UTC] derick@php.net
IT would require a whole new parser, just to do this. And it is not really hard to code such a function in PHP itself.
Also note that header is meant to set raw HTTP headers, and this would change that behavior.

I'm closing this, as I see no use for this, except for a little convenience.

Derick
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Jun 18 13:00:01 2026 UTC