dongming8867 2012-01-26 08:25
浏览 246
已采纳

如何检查php中是否启用了mod_rewrite?

I was wondering if it is possible to check if mod_rewrite is enabled on Apache AND IIS in PHP.

ModRewrite for IIS exists. Check it here.

So, I'm looking for a PHP script that checks for mod_rewrite on Apache and IIS.

Does anyone know such script or can write one?

Especially for Microsoft IIS.

Thanks!

  • 写回答

14条回答 默认 最新

  • douxuanou2787 2012-01-26 08:30
    关注

    If you're using mod_php, you can use apache_get_modules(). This will return an array of all enabled modules, so to check if mod_rewrite is enabled, you could simply do

    in_array('mod_rewrite', apache_get_modules());
    

    Unfortunately, you're most likely trying to do this with CGI, which makes it a little bit more difficult.

    You can test it using the following, though

    strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false
    

    If the above condition evaluates to true, then mod_write is enabled.

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部