Skip to content

Instantly share code, notes, and snippets.

@white-gecko
Created March 11, 2014 11:02
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 white-gecko/9483661 to your computer and use it in GitHub Desktop.
Save white-gecko/9483661 to your computer and use it in GitHub Desktop.
Proxy script for rewritng purl redirected URIs to the correct URLs for OntoWiki
<?php
$request = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['REQUEST_URI']);
$purl = 'http://purl.org' . $request;
$proxyTarget = array(
'/voc/ex/' => 'http://example.org/site/schema/?r=',
);
foreach ($proxyTarget as $path => $target) {
if (strpos($request, $path) === 0) {
$redirect = $target . urlencode($purl);
echo 'redirect to ' . $redirect;
header('location: ' . $redirect);
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment