Created
July 8, 2016 19:04
-
-
Save JoseRivas1998/7492598182705fc735d27894d873e859 to your computer and use it in GitHub Desktop.
Changing header based on request uri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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