問題描述
我想知道是否可以檢查 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?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!