Search code examples
phpapachebrowserbrowscap

How can I add more entry to browscap.ini file?


The official browscap.ini files provided there works quite fine, but they can not seem to identify Opera running on Win8 (identified as 'Default Browser', Opera running on other versions of Windows seems to be identified correctly), the Epiphany browser (identified as Chromium).

How can I add more entry to the file or get a modified, more complete version? Or is my problem a one that can not be solved by browscap.ini alone?


Solution

  • The addition itself is very simple, you just need to add the browsers in the correct format, that looks like this:

    [IE 6.0]
    browser=IE
    Version=6.0
    majorver=#6
    minorver=#0
    frames=True
    tables=True
    cookies=True
    backgroundsounds=True
    vbscript=True
    javaapplets=True
    javascript=True
    ActiveXControls=True
    Win16=False
    beta=False
    AK=False
    SK=False
    AOL=False
    Update=False
    
    [Mozilla/4.0 (compatible; MSIE 6.0; Windows 98*)]
    parent=IE 6.0
    platform=Win98
    beta=True
    
    [Mozilla/4.0 (compatible; MSIE 6.0; Windows NT*)]
    parent=IE 6.0
    platform=WinNT
    beta=True
    
    [Mozilla/4.0 (compatible; MSIE 6.0)]
    parent=IE 6.0
    
    
    [IE 6.0b]
    browser=IE
    Version=6.0
    majorver=#6
    minorver=#0
    frames=True
    tables=True
    cookies=True
    backgroundsounds=True
    vbscript=True
    javaapplets=True
    javascript=True
    ActiveXControls=True
    Win16=False
    beta=True
    AK=False
    SK=False
    AOL=False
    Update=False
    
    
    [Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98*)]
    parent=IE 6.0
    platform=Win98
    beta=True
    
    [Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT*)]
    parent=IE 6.0
    platform=WinNT
    beta=True
    
    [Mozilla/4.0 (compatible; MSIE 6.0b)]
    parent=IE 6.0b
    

    The fun part will probably be finding your browscap.ini. It's location depends on your server.

    In a windows server look for it in %systemroot%\WINNT\System32\Inetsrv folder.

    In a Linux Server, you might want to put it in /etc/extra/
    Then go to your php.ini file and declare it like this: browscap = /etc/extra/browscap.ini
    And finally reboot your server.

    If you are using a rented server you might not have access to the file and will need to contact your hosting provider to do any changes.

    Finally, once you locate the file (or created it if it doesn't exist) just edit it with notepad (or text edit if you're a mac user)

    Good luck! I hope this helps.