Apache-2.2

Apache 尾部斜杠添加到文件問題

  • February 23, 2011

我遇到了 Apache 的問題。它的作用是:獲取 /index.php 文件,其中包含一個將 src 設置為相對路徑 myimg.jpg 的程式碼,兩者都在我的伺服器的根目錄中。因此,www.mysite.com 會像 www.mysite.com/index.php 一樣顯示圖像。

但是,如果我訪問 www.mysite.com/index.php/ (帶有斜杠),它會執行 index.php 程式碼,因為它會在 index.php 文件夾中(例如 /index.php/index .php),因此不再顯示圖像。

這是一個簡單的例子,很容易通過絕對定址等解決,我從中得到的問題是一個不容易解決的安全問題。

那麼,當文件被“作為文件夾”訪問時,如何讓 Apache 給出 403 或 404 呢?

謝謝你。

“AcceptPathInfo off”會阻止 Apache 將請求映射到 /index.php/ 到 index.php + PATH_INFO of “/”。

引用自:https://serverfault.com/questions/239178