Skip to content

Instantly share code, notes, and snippets.

@CyberShadow
Last active April 20, 2020 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CyberShadow/58df32ed1dbe64fffd0545f87d9321ad to your computer and use it in GitHub Desktop.
Save CyberShadow/58df32ed1dbe64fffd0545f87d9321ad to your computer and use it in GitHub Desktop.
RewriteEngine On
RewriteRule test\.php - [L]
RewriteRule .* test.php?res=$0 [L]
<?php
header('Content-Type: text/plain');
switch ($_GET['res'])
{
case 'testUrl1':
echo "Hello world\n";
break;
case 'testUrl2':
# TODO
break;
case 'testUrl3':
header('Location: testUrl2');
echo "Moved!\n";
break;
case 'testUrl4':
readfile("php://input");
break;
case 'testUrl5':
header('HTTP/1.1 202 Custom Message');
header('Test-Response-Header: baz');
echo $_SERVER['REQUEST_METHOD'].' '.$_SERVER['HTTP_TEST_REQUEST_HEADER'].' ';
readfile("php://input");
break;
default:
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
echo "Not Found: ${_GET['res']}\n";
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment