国家特定的购物车 [英] Country Specific Shopping Cart

查看:109
本文介绍了国家特定的购物车的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在建设一个购物车的客户,但他想要不同的版本不同的国家,所以为此我创建2子域的一个叫做europe.website.com和一个叫row.website.com

 在我的.htaccess我也有这个...
#使所有的请求都万维网在其中
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^网站\ .COM
重写规则^(。*)$ https://www.website.com/$1 [R =永久,L]
 

只是所以它迫使WWW。在网站上,但这应该不会影响到子域,但是却因为它的https我得到一个安全风险,例如

  

本网站psented的安全证书$ P $是为一个发行   不同的网站的地址。

     

安全证书问题可能表示在欺骗你的企图或   截获您发送到服务器的任何数据。

     

我们建议您关闭此网页,并且不要继续这个   网站

因此​​多数民众赞成第一个问题,因为你可以看到有!第二个问题是,它不重定向到这些子域,我想不通为什么!这里是我用在我的index.php在主网站上的PHP code座....

 < PHP
$ LC =;
如果(使用isset($ _ SERVER ['HTTP_ACCEPT_LANGUAGE'])){
    $ LC = SUBSTR($ _ SERVER ['HTTP_ACCEPT_LANGUAGE'],0,2);
}
如果($ LC ==阵列(AB,广告,AE,AF,股份公司,人,点,AO,水溶液,AA,AF ,平,点,芳,一个,AC,如,AW,斧头,AZ,BB,BD,BF, BG,BH,比,北京,兽王,国阵,博,BR,BS,BT,BV,体重,由,BZ,CA,CC,CD,CF, "cg","ci","ck","cl","cm","cn","co","cr","cu","cv","cx","dj","dm","do","dz","ec","ee","eg","eh","er","et","fj","fk","fm","fo","fx","ga","gd","ge","gf","gh","gl","gm","gn","gp","gq","gs","gt","gu","gw","gy","hk","hm","hn","ht","id","il","in","io","iq","ir","is","jm","jo","jp","ke","kg","kh","kl","km","kn","kp","kr","kw","ky","kz","la","lb","lc","lr","ls","ly","ma","md","me","mf","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","np","nr","nt","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pw","py","qa","re","ru","rw","sa","sb","sc","sd","sg","sh","sj","sl","sn","so","sr","ss","st","su","sv","sy","sz","tc","td","tf","tg","th","tj","tk","tm","to","tp","tr","tt","tv","tw","tz","ug","um","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","ye","yt","yu","za","zm","zr","zw")){
    标题(位置:https://row.website.com/index.php);
    出口();
}否则,如果($ LC ==阵列(一,在,巴,是,CH,CS,CY,CZ,德,DK, ES,欧洲,FL,FR,FX,GI,遗传资源,人力资源,虎,IE,它,礼,LT ,吕氏春秋,LV,三菱商事,山,NL,没有,PT,RS,RO,SE,SL,SK, SM,TN,UA,英国,XK)){
    标题(位置:https://europe.website.com/index.php);
    出口();
}
?>
 

由于我在英国,我决定加入英国,以重定向到我的欧子域,但没有这样的运气,并要求其他朋友在美国检查出的网站,看看它是否重定向,但仍数组没有快乐,因为它只是停留在主域!

任何人有任何线索?在此先感谢!

-Phillip露水

更新

好了所有我又改变了这一切,我已经请人在国外,检查网站,但它仍然没有重定向!这里是我的code ....

 < PHP
$ LST ['欧元'] =阵列(是,BS,ECT等...);
$ LST ['等'] =阵列(AB,AA,AF);
$ LC =;
如果(使用isset($ _ SERVER ['HTTP_ACCEPT_LANGUAGE'])){
    $ LC = SUBSTR($ _ SERVER ['HTTP_ACCEPT_LANGUAGE'],0,2);
}
否则$ LC ='恩';
如果(in_array($ LC,$善堂['其他'])){
    标题(位置:https://www.WEBSITE.com/row/index.php);
    出口();
}
ELSEIF(in_array($ LC,$善堂['欧元'])){
    标题(位置:https://www.WEBSITE.com/europe/index.php);
    出口();
}
其他 {
    标题(位置:https://www.WEBDESITE.com/index.php);
    出口();
}
?>
 

决定摆脱子域的SSL不会对他们的工作,只是增加2个新的目录到它,而不是!

再次感谢很多提前一切! -Phillip露水

解决方案

  $ L code =爆炸(;,$ _ SERVER ['HTTP_ACCEPT_LANGUAGE']);
$ L code =爆炸(,$ L code [0]);
$ LC = $ L code [0];
 

但是,也许这让你得到同样的结果...

编辑:只是检查什么语言code,你得到什么? 回声$ LC;

此外,您还需要提供一个默认的语言(也许'恩'),如果$ _ SERVER ['HTTP_ACCEPT_LANGUAGE']没有设置。

编辑:您还需要重定向到一个默认域如果语言code不是在任何你的两个阵列。例如,如果在code是'恩'发生什么呢?你为什么不有'恩'顶阵列中的?

更新:OK,你也有你的PHP逻辑语句中的错误。使用 in_array(),像这样的:

 < PHP
  $ lst_euro =阵列(阵列(一个,在,...);
  $ lst_other =阵列(阵列(AB,广告,...);
  $ LC =;
  如果(使用isset($ _ SERVER ['HTTP_ACCEPT_LANGUAGE'])){
    $ LC = SUBSTR($ _ SERVER ['HTTP_ACCEPT_LANGUAGE'],0,2);
  }
  否则$ LC ='恩';
  如果(in_array($ LC,$ lst_other)){
      标题(位置:https://row.website.com/index.php);
      出口();
  }
  ELSEIF(in_array($ LC,$ lst_euro)){
    标题(位置:https://europe.website.com/index.php);
    出口();
  }
  其他 {
    标题(位置:https://row.website.com/index.php);
    出口();
  }
 

?>

I am currently building a shopping cart for a client but he wants different versions for different countries, so to that end I created 2 subdomains one called europe.website.com and one called row.website.com

On my .htaccess I also have this...
# Make all requests have www in them
RewriteEngine On
RewriteCond %{HTTP_HOST} ^website\.com
RewriteRule ^(.*)$ https://www.website.com/$1 [R=permanent,L] 

just so it forces the www. on the site but this should make no difference to the subdomain but however as it has 'https' I get a security risk e.g.

The security certificate presented by this website was issued for a different website's address.

Security certificate problems may indicate an attempt to fool you or intercept any data you send to the server.

We recommend that you close this webpage and do not continue to this website.

so thats the first problem as you can see there! The second problem is that it does not redirect to those subdomains and i cannot figure out why! here is a php code block I have used on my index.php on the main website....

<?php
$lc = ""; 
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
    $lc = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
if($lc == array("ab", "ad","ae","af","ag","al","am","ao","aq", "aa", "af", "sq", "am", "ar", "an", "ac", "as", "aw", "ax", "az", "bb", "bd", "bf", "bg", "bh", "bi", "bj", "bm", "bn", "bo", "br", "bs", "bt", "bv", "bw", "by", "bz", "ca", "cc", "cd", "cf", "cg","ci","ck","cl","cm","cn","co","cr","cu","cv","cx","dj","dm","do","dz","ec","ee","eg","eh","er","et","fj","fk","fm","fo","fx","ga","gd","ge","gf","gh","gl","gm","gn","gp","gq","gs","gt","gu","gw","gy","hk","hm","hn","ht","id","il","in","io","iq","ir","is","jm","jo","jp","ke","kg","kh","kl","km","kn","kp","kr","kw","ky","kz","la","lb","lc","lr","ls","ly","ma","md","me","mf","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","np","nr","nt","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pw","py","qa","re","ru","rw","sa","sb","sc","sd","sg","sh","sj","sl","sn","so","sr","ss","st","su","sv","sy","sz","tc","td","tf","tg","th","tj","tk","tm","to","tp","tr","tt","tv","tw","tz","ug","um","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","ye","yt","yu","za","zm","zr","zw")){
    header("location: https://row.website.com/index.php");
    exit();
} else if($lc == array("an", "at", "ba", "be", "ch", "cs", "cy","cz", "de", "dk", "es", "eu", "fl", "fr", "fx", "gi", "gr", "hr", "hu", "ie", "it", "li", "lt", "lu", "lv", "mc", "mt", "nl", "no", "pt", "rs","ro", "se", "sl", "sk", "sm", "tn", "ua", "uk", "xk" )){
    header("location:  https://europe.website.com/index.php");
    exit();
}
?>

As I am based in the UK I decided to add "uk" to the array that redirects to my europe subdomain but no such luck and have asked other friends in the states to check out the site and see if it redirects but still no joy as it just stays on the main domain!

anyone got any clues? thanks in advance!

-Phillip Dews

UPDATE

Ok all I have changed it all again and I have asked people abroad to check the site but its still not redirecting! here is my code....

<?php
$lst ['euro'] = array("be","bs",ECT ECT...);
$lst ['other'] = array("ab","aa","af");
$lc = ""; 
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
    $lc = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
else $lc = 'en';
if(in_array($lc, $lst['other'])){
    header("location: https://www.WEBSITE.com/row/index.php");
    exit();
}
elseif (in_array($lc, $lst['euro'])) {
    header("location: https://www.WEBSITE.com/europe/index.php");
    exit();
}
else {
    header("location: https://www.WEBDESITE.com/index.php");
    exit();
}
?>

decided to get rid of the subdomains as the ssl does not work on them and just add 2 new directories to it instead!

Once again many thanks in advance all! -Phillip Dews

解决方案

$lcode = explode(";", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$lcode = explode(",", $lcode['0']);
$lc = $lcode['0'];

But maybe this gives the same result you get...

EDIT: Just check what language code you get? echo $lc;

Also, you need to provide a default language (maybe 'en') if $_SERVER['HTTP_ACCEPT_LANGUAGE'] is not set.

EDIT: You also need to redirect to a default domain if the language code is not in either of your two arrays. For instance, what happens if the code is 'en'? Why don't you have 'en' in the top array?

UPDATE: OK, you also have errors in your php logic statements. Use in_array(), like this:

<?php
  $lst_euro = array(array("an", "at", ...);
  $lst_other = array(array("ab", "ad", ...);
  $lc = ""; 
  if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
    $lc = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
  }
  else $lc = 'en';
  if(in_array($lc, $lst_other)){
      header("location: https://row.website.com/index.php");
      exit();
  } 
  elseif(in_array($lc, $lst_euro)) {
    header("location: https://europe.website.com/index.php");
    exit();
  }
  else {
    header("location: https://row.website.com/index.php");
    exit();
  }

?>

这篇关于国家特定的购物车的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆