PHP代码:
<?php if(preg_match("/zh-cn/is",$_SERVER['HTTP_ACCEPT_LANGUAGE'])){ @header("Location:http://www.sina.com.cn"); }else{ @header("Location:http://www.sohu.com"); } ?> |
ASP代码:
<% dim re re = New RegExp re.Pattern = "zh-cn" re.IgnoreCase = true re.Global = true if re.Test(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")) then Response.Redirect("http://www.sina.com.cn") else Response.Redirect("http://www.sohu.cn") end if %> |
JavaScript代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="utf-8" > <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Redirect URL</title> </head> <body> <script language="javascript" type="text/javascript"> var language = window.navigator.userLanguage || window.navigator.language; if(/zh-cn/ig.test(language)){ location.replace("http://www.sina.com.cn"); }else{ location.replace("http://www.sohu.com"); } </script> </body> </html> |
[email protected]evlos: 也许这也能从某种程度上证明PHP代码最有效率吧 ,哈哈·· 😕
嘻嘻,果然还是PHP语言写起来最短 ~ O(∩_∩)O ~
订阅你咯,嘎嘎嘎 ~
好有学问啊!!
@cyusyu: 双语外贸站用的比较多,就跟GOOGLE.COM在中国访问中文,在美国访问时英文一个道理。
不太明白 🙄