Skip to content

Instantly share code, notes, and snippets.

@barbwiredmedia
Last active October 10, 2022 15:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save barbwiredmedia/c5dbd557520b93b633ad to your computer and use it in GitHub Desktop.
Save barbwiredmedia/c5dbd557520b93b633ad 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/' ) ;
} ?>
@MrDoxxer2
Copy link

I don't understand of what it will do if the referre is correct

@Zenexya
Copy link

Zenexya commented Aug 13, 2022

@MrDoxxer2 if the page that redirected you to the referer.php is equal to url.com then it does something. Otherwise redirect it to something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment