How to check if mod_rewrite is enabled in php?(如何检查是否在 php 中启用了 mod_rewrite?)
问题描述
我想知道是否可以检查 mod_rewrite
是否在 Apache 和 IIS 上启用,PHP
.
I was wondering if it is possible to check if mod_rewrite
is enabled on Apache AND IIS in PHP
.
ModRewrite.在此处
检查.
所以,我正在寻找一个 PHP 脚本来检查 Apache 和 IIS 上的 mod_rewrite
.
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?
特别适用于 Microsoft IIS.
Especially for Microsoft 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
如果上述条件的计算结果为 true
,则启用 mod_write
.
If the above condition evaluates to true
, then mod_write
is enabled.
这篇关于如何检查是否在 php 中启用了 mod_rewrite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何检查是否在 php 中启用了 mod_rewrite?
基础教程推荐
- PHP 守护进程/worker 环境 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01