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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度