Skip to content

Instantly share code, notes, and snippets.

@Koala
Created December 3, 2012 21:42
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 Koala/4198355 to your computer and use it in GitHub Desktop.
Save Koala/4198355 to your computer and use it in GitHub Desktop.
function wl301($var, $zielurl)
<?php
/**
* Führt 301-Weiterleitung auf angegebenes Ziel aus.
*
* @param string $var Variable auf die geprueft wird
* @param string $zielurl Ziel-URL inkl. http://
*/
function wl301($var, $zielurl) {
$url = $_SERVER['REQUEST_URI'];
$parts = parse_url($url);
if(isset($parts['query'])) {
parse_str(urldecode($parts['query']), $partss);
if (array_key_exists($var, $partss)) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: $zielurl");
header("Connection: close");
}
}
}
wl301('v','http://localhost/aphorismen4_4/index.php?article_id=2');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment