錯誤:在 Apache 2 中,apache_lookup_uri("/directory") 會顯示警告且無法回傳任何值。 apache_lookup_uri("/directory/") 可以正常運作。
另一個錯誤:virtual("something") 會強制清空標頭。我知道這有記錄在文件中,但如果它不要這樣做會更好。當您使用 virtual() 來包含動態檔案(例如 PHP 或 Perl 檔案)時,您永遠不會想要清空標頭,這表示 virtual() 無法用於大多數網站的內容 :-(。(PHP 4, PHP 5, PHP 7, PHP 8)
apache_lookup_uri — 對指定的 URI 執行部分請求並返回關於它的所有資訊
這會對 URI 執行部分請求。它只進行到足以獲取有關給定資源的所有重要資訊。
當 PHP 作為 Apache 模組網路伺服器安裝時,支援此函式。
檔名被請求的檔案名稱(URI)。
失敗時回傳 false。
範例 #1 apache_lookup_uri() 範例
<?php
$info = apache_lookup_uri('index.php?var=value');
print_r($info);
if (file_exists($info->filename)) {
echo 'file exists!';
}
?>上述範例會輸出類似以下的內容:
stdClass Object
(
[status] => 200
[the_request] => GET /dir/file.php HTTP/1.1
[method] => GET
[mtime] => 0
[clength] => 0
[chunked] => 0
[content_type] => application/x-httpd-php
[no_cache] => 0
[no_local_copy] => 1
[unparsed_uri] => /dir/index.php?var=value
[uri] => /dir/index.php
[filename] => /home/htdocs/dir/index.php
[args] => var=value
[allowed] => 0
[sent_bodyct] => 0
[bytes_sent] => 0
[request_time] => 1074282764
)
file exists!
錯誤:在 Apache 2 中,apache_lookup_uri("/directory") 會顯示警告且無法回傳任何值。 apache_lookup_uri("/directory/") 可以正常運作。
另一個錯誤:virtual("something") 會強制清空標頭。我知道這有記錄在文件中,但如果它不要這樣做會更好。當您使用 virtual() 來包含動態檔案(例如 PHP 或 Perl 檔案)時,您永遠不會想要清空標頭,這表示 virtual() 無法用於大多數網站的內容 :-(。這是一個非常有用的函式,但它不會顯示所有輸出。例如,我只看到
[status]
[the_request]
[method]
[mtime]
[clength]
[chunked]
[content_type]
[no_cache]
[no_local_copy]
[unparsed_uri]
[uri]
[filename]
[path_info]
[allowed]
[sent_bodyct]
[bytes_sent]
[request_time]一個有用的特性是,如果您啟用了內容協商 (Options MultiViews),Apache 會盡可能為您解決協商。因此,www.example.com/blah 將會根據情況解析為 /base/blah.php 或 /base/blah.html 甚至 /base/blah.en.html。