【问题标题】:How to detect mod_rewrite without apache_get_modules()?如何在没有 apache_get_modules() 的情况下检测 mod_rewrite?
【发布时间】:2009-08-20 00:36:15
【问题描述】:

当函数apache_get_modules()不可用时,是否可以在PHP中检测到mod_rewrite

【问题讨论】:

    标签: php apache mod-rewrite


    【解决方案1】:

    你可以分析phpinfo()的输出:

    ob_start();
    phpinfo(INFO_MODULES);
    $contents = ob_get_contents();
    ob_end_clean();
    var_dump(strpos($contents, 'mod_rewrite') !== false);
    

    【讨论】:

    • 哇,不错,我没想到。顺便提一句。你可以使用 ob_get_clean() 函数。
    • 但是ob_get_clean 不会结束缓冲区,所以无论如何你都需要另一个ob_end_* 调用。
    • 确实如此。在文档中是:ob_get_clean() 本质上同时执行 ob_get_contents() 和 ob_end_clean()。
    • 请注意,当 PHP 运行 FCGI 时,这似乎不起作用。就 apache 模块而言,在 INFO_MODULES 中没有看到任何内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多