0

我们制作了两个版本的安装包,win-32.msi和win-64.msi,放到我们的网站上供用户下载。

但我只想使用一个网络链接。当用户使用windows-32位操作系统点击链接时,他会得到win-32.msi,使用windows-64位操作系统会得到win-64.msi。

我们在 web 代码中使用 php、js、html,在 apache 中设置。

我们之前使用过一个方法:browsercap.ini。但是我们发现win8-64bit的IE10浏览器给我们win8-32bit的信息是错误的。

那么还有其他解决方案吗?

4

2 回答 2

1

As an alternative you can do this in Apache as well by using mod_rewrite and looking at the HTTP_USER_AGENT variable. More information about this can be found in the mod_rewrite documentation.

Something like this could work:

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} (WOW64|OtherMatch)
RewriteRule ^(/path/to/dl-packages)/win-32.msi $1/win-64.msi [R,L]

This is more to show the basic consept and you might want to fine tune the (WOW64|OtherMatch) string that should match the 64bit clients, not sure if WOW64 will match all Windows 64 bit browsers. Also I am matching the URL to the win-32.msi package in my RewriteRule that would be the default package, and if a 64bit client try to get it it will be redirected to the 64 bit version instead. Depending on your site, you might want to handle this differently.

于 2013-10-16T07:05:17.237 回答
1

在 Javascript 中,您可以使用navigator对象来获取有关本地系统的一些信息:

console.log(navigator.appVersion);    

在我的系统上,这会产生:

5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36

然后,您可以对其进行解析以找出将用户发送到何处。

于 2013-10-16T06:05:05.457 回答