Created
March 11, 2014 11:02
-
-
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
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 | |
$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