私は時々私のさまざまなウェブサイト上の製品を参照します, 通常はそれらを買うことに興味がある人のためにアマゾンにリンクします. 昔、私は、Amazonアフィリエイトリンクをしてリンクするために使用されるが、私の典型的な読者がよく世界中に分散しているとして、そこから何かを獲得したことはありません. 残念ながら、Amazonは関連会社の支払いに維持しながら、地元のアマゾンのサイトへの訪問者をリダイレクトする方法を提供していません。. そこに出て様々なソリューションがありますが、私が見つけたすべてのものは、それらの問題を持っていました, 私は自分自身を開発しました.
I could develop it into a plugin for release if there is sufficient demand. 平均時間の, コードは以下の通りです. 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: Jon P Scaife * Author URI: https://jonscaife.com * License: GPL12 */ function process_link() { $debug=false; //Detect visitor location from IP もし (isset($_サーバ['HTTP_CLIENT_IP'])) { $real_ip_address = $_SERVER['HTTP_CLIENT_IP']; } もし (isset($_サーバ['HTTP_X_FORWARDED_FOR'])) { $real_ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; } ほかに { $real_ip_address = $_SERVER['REMOTE_ADDR']; } function curl_get_contents($URL) { $CH = curl_init(); ますcurl_setopt($CH, CURLOPT_HEADER, 0); ますcurl_setopt($CH, CURLOPT_RETURNTRANSFER, 1); ますcurl_setopt($CH, CURLOPT_URL, $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($_サーバ['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 'GB': $link="https://www.amazon.co.uk/dp/".$linkpartone."/ref=nosim?tag=dimeho-21"; break; case 'IE': $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) { エコー "1. $iplocation. 2. $browserlang. 3. $userlang. 4. $リンク"; } ほかに { ヘッダー('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= str_replace('<REL ="nofollowを" HREF ="https://www.amazon', '<スクリプト>var ran_var= Math.random();</スクリプト><a style="background: なし;" REL ="nofollowを" onclick="location.href=this.href+\'?ran=\'+ran_var;falseを返します;" target="_blank" HREF ="https://jonscaife.com/wp-content/plugins/amazon-affiliates-redirect.php?addr=', $コンテンツ); 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;falseを返します;" target="_blank" HREF ="https://jonscaife.com/wp-content/plugins/amazon-affiliates-redirect.php?addr=', $コンテンツ); } ADD_FILTER( 'the_content', 'modify_amazon_affiliate_links' ) ?>
Note — the code is currently early draft. できます, 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)…”