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 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题