如何检查是否mod_rewrite并在PHP启用? [英] How to check if mod_rewrite is enabled in php?

查看:280
本文介绍了如何检查是否mod_rewrite并在PHP启用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果有可能,以检查是否的mod_rewrite 在<强在阿帕奇 IIS 启用> PHP

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

ModRewrite 作为IIS存在。检查 此处

ModRewrite for IIS exists. Check it here.

所以,我在找一个PHP脚本,检查的mod_rewrite 阿帕奇 IIS。

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?

特别是对微软的 IIS

谢谢!

推荐答案

如果你使用mod_php,并且可以使用 apache_get_modules()。这将返回所有启用的模块组成的数组,所以要检查的mod_rewrite 已启用,你可以简单地做

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());

不幸的是,你最有可能试图用CGI做到这一点,这使得它更困难一点。

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

如果上述条件计算结果为真正,那么 mod_write 已启用。

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

这篇关于如何检查是否mod_rewrite并在PHP启用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆