Skip to content

Instantly share code, notes, and snippets.

@gnrfan
Created March 27, 2013 00:36
Show Gist options
  • Select an option

  • Save gnrfan/5250610 to your computer and use it in GitHub Desktop.

Select an option

Save gnrfan/5250610 to your computer and use it in GitHub Desktop.
You can upload this simple PHP script to a public server on the Internet and receive there callbacks from webservices like Facebook's Graph API and have it redirect the request to localhost or any other non-public URI.
<?php
define('APP_PREFIX', '/path/to/subfolder/if/any/');
define('REDIRECT_TARGET', 'http://localhost:8000/');
if (array_key_exists('redirect_target', $_REQUEST)) {
$redirect_base = $_REQUEST['redirect_target'];
} else {
$redirect_base = REDIRECT_TARGET;
}
$url = $_SERVER['REQUEST_URI'];
$url = str_replace(APP_PREFIX, $redirect_base, $url);
header("Location: $url");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment