douzuo0711 2012-02-25 12:58
浏览 47
已采纳

在服务器上使用htaccess更改PHP.ini

I am trying to use PHP's built-in function get_browser(). I followed the instructions in this useful post, but I'm still getting the error

browscap ini directive not set.

I downloaded the php_browscap.ini file and moved it into the same directory as my .htaccess file, so that its location is home/hostname/subdomain/php_browscap.ini Since I do not have access to my php.ini file, I am trying to edit the browscap property using .htaccess. This is what I entered:

php_value browscap home/hostname/subdomain/php_browscap.ini

I don't know if it matters, but below that there's some Rewrite Engine code.

As forementioned, I am still getting the error above. What did I do wrong?

Thanks.

  • 写回答

4条回答 默认 最新

  • dsfsfsfsfs55656 2012-02-25 15:18
    关注

    Do a phpinfo() to understand your PHP runtime config. If your system is configure as "CGI/FastCGI" then it is probably running suPHP as the PHP initiator. In this case you can specify your own php.ini file. By default suPHP looks in the script directory but you can override this by the following directive in your .htaccess file:

    suPHP_ConfigPath (expects a path name)
    

    This option tells mod_suphp which path to pass on to the PHP-interpreter (by setting the PHPRC environment variable). Do NOT refer to a file but to the directory the file resists in.

    E.g.: If you want to use "/path/to/server/config/php.ini", use "suPHP_Config/path/to/server/config".

    If you don't use this option, PHP will use its compiled in default path. Also you must use a properly formed path in your browsercap directive e.g.

    browscap="/home/hostname/subdomain/php_browscap.ini"
    

    (Note the leading /)

    Addendum

    I've just check and the Dreamhost shared hosting plan uses suEXEC. With suEXEC you can normally override the php.ini patch by copying the system php.ini (phpinfo() tells you where to find this) into a private directory, say _private as well as the browsercap.ini then adding

    SetEnv PHPRC /home/hostname/_private
    

    to your .htaccess file. If this doesn't work then the issue is specific to Dreamhost's suEXEC config and you need to ask this Q on http://discussion.dreamhost.com/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看