[請益] 請問如何讓不存在的路徑指向 index.php?

看板PHP作者 (egg)時間17年前 (2008/06/14 04:38), 編輯推噓3(301)
留言4則, 3人參與, 最新討論串1/2 (看更多)
假設我有 example.com,而裡面除了 index.php 外沒有其他路徑或檔案。 請問要如何讓 example.com/foo 也可以顯示首頁(index.php)呢? 現在我只能看到 404, 希望可以讓所有不存在的路徑 wildcard 出現首頁。 不知是要在 web server 還是哪裡做設定。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 65.194.77.134

06/14 05:16, , 1F
如果是Apache的話google搜尋mod_rewrite
06/14 05:16, 1F

06/14 10:26, , 2F
ErrorDocument index.php
06/14 10:26, 2F

06/14 10:26, , 3F
redirect example.com/foo/* index.php
06/14 10:26, 3F

06/14 16:37, , 4F
會比較不推mod_rewrite,會有點小耗資源
06/14 16:37, 4F
文章代碼(AID): #18KjhVJu (PHP)
文章代碼(AID): #18KjhVJu (PHP)