Skip to content

Instantly share code, notes, and snippets.

@robertstaddon
Created February 24, 2017 20:43
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 robertstaddon/db98d8c8d87746730a18b2a8d0b55144 to your computer and use it in GitHub Desktop.
Save robertstaddon/db98d8c8d87746730a18b2a8d0b55144 to your computer and use it in GitHub Desktop.
Rewrite POST data
<?php
if($_POST) {
$postdata = http_build_query($_POST);
$opts = array('http' =>array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
$context = stream_context_create($opts);
$result = file_get_contents("https://mynewdomain.com$_SERVER[REQUEST_URI]", false, $context);
echo $result;
} else {
header("Location: https://mynewdomain.com$_SERVER[REQUEST_URI]");
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment