Skip to content

Instantly share code, notes, and snippets.

@salvatorecapolupo
Created September 21, 2019 10:09
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 salvatorecapolupo/254a78c356aa9639c7e59b59fe763bf8 to your computer and use it in GitHub Desktop.
Save salvatorecapolupo/254a78c356aa9639c7e59b59fe763bf8 to your computer and use it in GitHub Desktop.
This is useful for some backlinks "recovery".
<?PHP
function smart_seo_redirect(){
if ( isset($_SERVER['HTTP_REFERER']) ){
$referrer = $_SERVER['HTTP_REFERER'];
$parse = parse_url($referrer);
$referrer = $parse['host'];
$matches = [];
$matches[]= preg_match('/cool_referral_name/', $referrer, $matches);
$matches[]= preg_match('/cool_referral_substring/', $referrer, $matches);
// ... add as many as you want
$url = "https://sitereceivingbacklinks.com";
if ( sizeof( $matches ) > 0 ) {
{
wp_redirect( $url ) ;
exit;
}
}
}
}
add_action('init', 'process_post');
function process_post(){
smart_seo_redirect();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment