Skip to content

Instantly share code, notes, and snippets.

@zaigham
Created February 9, 2011 10:13
Show Gist options
  • Save zaigham/818247 to your computer and use it in GitHub Desktop.
Save zaigham/818247 to your computer and use it in GitHub Desktop.
<?php
/* Virtual aliases
* Patrick Nijkamp
* http://www.1-vision.nl
* When installed create a property in the DEFAULT property set called "tvID"
* and fill it with the ID of the TV that hold's the old URL.
* Old URL's without '/' at the start.
*/
$aliasTvId = $scriptProperties['tvId'];
$match = $modx->getObject('modTemplateVarResource', array(
'value' => substr($_SERVER['REQUEST_URI'], 1),
'tmplvarid' => $aliasTvId
));
if ($match != null) {
header('HTTP/1.1 301 Moved Permanently');
$modx->sendRedirect($modx->makeUrl($match->get('contentid')), 0, 'REDIRECT_HEADER');
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment