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

How to check if mod_rewrite is enabled in php?(如何检查是否在 php 中启用了 mod_rewrite?)
本文介绍了如何检查是否在 php 中启用了 mod_rewrite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我想知道是否可以检查 mod_rewrite 是否在 ApacheIIS 上启用,PHP.

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

ModRewrite.在此处检查.

所以,我正在寻找一个 PHP 脚本来检查 ApacheIIS 上的 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)