Skip to content

Instantly share code, notes, and snippets.

@JoseRivas1998
Created July 8, 2016 19:04
Show Gist options
  • Select an option

  • Save JoseRivas1998/7492598182705fc735d27894d873e859 to your computer and use it in GitHub Desktop.

Select an option

Save JoseRivas1998/7492598182705fc735d27894d873e859 to your computer and use it in GitHub Desktop.
Changing header based on request uri
<?php
$uri = $_SERVER["REQUEST_URI"];
$sapi_type = php_sapi_name();
$resp = 404;
if(strcasecmp($uri, '/test/hello.php') == 0) {
$resp = 200;
}
if (substr($sapi_type, 0, 3) == 'cgi') {
if($resp == 200) {
header("Status: 200 OK");
} else {
header("Status: 404 Not Found");
}
} else {
if($resp == 200) {
header("HTTP/1.1 200 OK");
} else {
header("HTTP/1.1 404 Not Found");
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment