मैं कभी कभी मेरी विभिन्न वेबसाइटों पर उत्पादों को संदर्भित, और आम तौर पर उन्हें खरीदने में रुचि किसी के लिए अमेज़न से लिंक. एक लंबे समय पहले मैं एक अमेज़न सहयोगी कंपनियों लिंक के साथ लिंक किया है, लेकिन यह कुछ भी अर्जित कभी नहीं के रूप में अपने ठेठ पाठकों अच्छी तरह से दुनिया भर में वितरित किया जाता है. दुर्भाग्य से अमेज़न सहयोगी कंपनियों से भुगतान करने के लिए बनाए रखने, जबकि उनके स्थानीय अमेज़न साइट पर आने वाले रीडायरेक्ट करने के लिए एक तरह से प्रदान नहीं करते. वहाँ वहाँ बाहर विभिन्न समाधान कर रहे हैं, लेकिन सभी लोगों को मैंने पाया उन लोगों के साथ मुद्दों था, so I developed my own.
I could develop it into a plugin for release if there is sufficient demand. मतलब समय में, the code is below. You will need to make some modifications to make it match your site address and your amazon affiliates codes
<?PHP /** * Plugin Name: Amazon Affiliates Redirect * Plugin URI: hTTPS://diymediahome.org/ * विवरण: Redirects all amazon affiliates links to a local amazon store depending on visitors location. * संस्करण: 1.0 * Author: जॉन पी Scaife * Author URI: hTTPS://jonscaife.com * License: GPL12 */ function process_link() { $debug=false; //Detect visitor location from आईपी अगर (isset($_SERVER['HTTP_CLIENT_IP'])) { $real_ip_address = $_SERVER['HTTP_CLIENT_IP']; } अगर (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $real_ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; } अन्य { $real_ip_address = $_SERVER['REMOTE_ADDR']; } function curl_get_contents($यूआरएल) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $यूआरएल); $data = curl_exec($ch); curl_close($ch); return $data; } $iptolocation = 'https://ip-api.com/php/' . $real_ip_address; $ipreply = @unserialize(curl_get_contents($iptolocation)); $iplocation = $ipreply['countryCode']; //Detect visitor language from browser $browserlang= substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); //Detect language of page visitor is using if (isset($_GET['lang'])) { $userlang= $_GET['lang']; } अन्य { $userlang= "EN"; } //was a link passed if (isset($_GET['addr'])) { $original_link= $_GET['addr']; } //Decide best amazon site based on data detected $linkpartone= $_GET['creativeASIN']; स्विच ($iplocation) { case 'जीबी': $link="hTTPS://www.amazon.co.uk/dp/".$linkpartone."/ref=nosim?tag=dimeho-21"; break; case 'आईई': $link="hTTPS://www.amazon.co.uk/dp/".$linkpartone."/ref=nosim?tag=dimeho-21"; break; case 'US': $link="hTTPS://www.amazon.com/dp/".$linkpartone."/ref=nosim?tag=jonstech-20"; break; case 'CA': $link="hTTPS://www.amazon.ca/dp/".$linkpartone."/ref=nosim?tag=dimeho-20"; break; case 'CN': $link="hTTPS://www.amazon.cn/dp/".$linkpartone."/ref=nosim?tag="; break; case 'HK': $link="hTTPS://www.amazon.cn/dp/".$linkpartone."/ref=nosim?tag="; break; case 'MO': $link="hTTPS://www.amazon.cn/dp/".$linkpartone."/ref=nosim?tag="; break; case 'IN': $link="hTTPS://www.amazon.in/dp/".$linkpartone."/ref=nosim?tag="; break; case 'JP': $link="hTTPS://www.amazon.co.jp/dp/".$linkpartone."/ref=nosim?tag="; break; case 'FR': $link="hTTPS://www.amazon.fr/dp/".$linkpartone."/ref=nosim?tag=Dimeho02-21"; break; case 'CH': $link="hTTPS://www.amazon.fr/dp/".$linkpartone."/ref=nosim?tag=Dimeho02-21"; break; case 'BE': $link="hTTPS://www.amazon.fr/dp/".$linkpartone."/ref=nosim?tag=Dimeho02-21"; break; case 'MC': $link="hTTPS://www.amazon.fr/dp/".$linkpartone."/ref=nosim?tag=Dimeho02-21"; break; case 'LU': $link="hTTPS://www.amazon.fr/dp/".$linkpartone."/ref=nosim?tag=Dimeho02-21"; break; case 'DE': $link="hTTPS://www.amazon.de/dp/".$linkpartone."/ref=nosim?tag=dimeho0f-21"; break; case 'CZ': $link="hTTPS://www.amazon.de/dp/".$linkpartone."/ref=nosim?tag=dimeho0f-21"; break; case 'IT': $link="hTTPS://www.amazon.it/dp/".$linkpartone."/ref=nosim?tag=diymediahome-21"; break; case 'NL': $link="hTTPS://www.amazon.nl/dp/".$linkpartone."/ref=nosim?tag="; break; case 'ES': $link="hTTPS://www.amazon.es/dp/".$linkpartone."/ref=nosim?tag=diymediahom05-21"; break; case 'MX': $link="hTTPS://www.amazon.com.mx/dp/".$linkpartone."/ref=nosim?tag="; break; case 'AU': $link="hTTPS://www.amazon.com.au/dp/".$linkpartone."/ref=nosim?tag="; break; case 'BR': $link="hTTPS://www.amazon.com.br/dp/".$linkpartone."/ref=nosim?tag="; break; चूक: $link="hTTPS://www.amazon.com/dp/".$linkpartone."/ref=nosim?tag=jonstech-20"; } अगर($debug==true) { echo "1. $iplocation. 2. $browserlang. 3. $userlang. 4. $link"; } अन्य { हैडर('Location: '.$link); die(); } } अगर (isset($_GET['addr'])) process_link(); //create filter to replace amazon links with internal redirect inc a random code to prevent caching function modify_amazon_affiliate_links($content) { $content= str_replace('<a rel="nofollow" href ="hTTPS://www.amazon', '<लिपि>var ran_var= Math.random();</लिपि><a style="background: कोई नहीं;" rel="nofollow" onclick="location.href=this.href+\'?ran=\'+ran_var;विवरण झूठा है;" target="_blank" href ="hTTPS://jonscaife.com/wp-content/plugins/amazon-affiliates-redirect.php?addr=', $content); return str_replace('<एक href ="hTTPS://www.amazon', '<लिपि>var ran_var= Math.random();</लिपि><a style="background: कोई नहीं;" rel="nofollow" onclick="location.href=this.href+\'?ran=\'+ran_var;विवरण झूठा है;" target="_blank" href ="hTTPS://jonscaife.com/wp-content/plugins/amazon-affiliates-redirect.php?addr=', $content); } add_filter( 'सामग्री', 'modify_amazon_affiliate_links' ) ?>
Note — the code is currently early draft. It works, but it doesn’t make use of some of the detection that it can do. It doesn’t have a settings page for the associate IDs, and it uses a hardcoded site address, rather than an invisible redirect. It DOES however use client-side javascript to generate a unique redirect url every time to prevent any caching systems from causing incorrect location detection.
“Hi James I realise it has been a long while, but I just checked this on windows 11 (build 23H2)…”