dongming8867 2012-01-26 16: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 16: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条)

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)