Created
September 21, 2019 10:09
-
-
Save salvatorecapolupo/254a78c356aa9639c7e59b59fe763bf8 to your computer and use it in GitHub Desktop.
This is useful for some backlinks "recovery".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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