![](/img/trans.png)
[英]How can I get the DirectoryIndex filename for a given URI using PHP?
[英]How can I get Apache's DirectoryIndex in PHP?
有沒有辦法在 Apache 下運行 PHP 中的 DirectoryIndex 的數組(或類似的東西)? 例如,我希望能夠檢查某個 DirectoryIndex 文件是否存在於特定目錄中。 這與如何使用 PHP 獲取給定 URI 的 DirectoryIndex 文件名有關? 但它並不完全問同樣的事情,所以盡管它相似,但請不要指向它。
編輯:我不希望 go 文件解析。
不幸的是不是,因為 Apache 不能通過environment variables使用它。
如果您可以控制配置,則可以在DirectoryIndex
旁邊使用setenv
指令。 然后使用apache_getenv()
在 PHP 中讀取它。
否則我認為你必須自己解析 Apache 配置文件。
您可以通過這種方式獲取DirectoryIndex
:
basename(apache_lookup_uri(realpath(urlencode('Path_directory_here')))->uri);
此方法僅適用於 Apache DSO 模塊運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.