Reputation: 534
We make two version setup packages, win-32.msi and win-64.msi, and put them to our website for user to download.
But I just want to using one web link. When user using windows-32bit OS to click the link, he would get the win-32.msi, using windows-64-bit OS would get win-64.msi.
We use php, js, html in our web code, setting in apache.
There was a method we used before: browsercap.ini. But we found IE10 browser in win8-64bit give us win8-32bit information which was wrong.
So are there any other solutions?
Upvotes: 0
Views: 548
Reputation: 2623
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.
Upvotes: 1
Reputation: 418
In Javascript you can use the navigator object to get some info about the local system:
console.log(navigator.appVersion);
On my system this yields:
5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36
You can then parse this to work out where to send the user.
Upvotes: 1