Skip to content

Instantly share code, notes, and snippets.

@jcamp
Forked from barbwiredmedia/referer.php
Created July 6, 2018 18:19
Show Gist options
  • Save jcamp/f950b5f6a1007bcd57e44c97047d9707 to your computer and use it in GitHub Desktop.
Save jcamp/f950b5f6a1007bcd57e44c97047d9707 to your computer and use it in GitHub Desktop.
Checking for page referer in php. Wordpress redirect or header refresh
<?php
//check for refering page to switch content based on referrer
$referrer = $_SERVER['HTTP_REFERER'];
if ($referrer == 'http://url.com' or $referrer == 'http://url-2.com') {
//Matches YES!
} else {
//Matches NO!
header( 'Location: http://www.url.com/no-soup-for-you/' ) ;
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment