如何使物理上不存在的頁面僅在某個目錄之後才連結到特定頁面?

如何使物理上不存在的頁面僅在某個目錄之後才連結到特定頁面?

我該如何做到這一點,以便當用戶訪問時mydomain.com/test/<any page after this point>顯示頁面mydomain.com/testhandler/並且不返回任何錯誤。舉個例子,我有一個系統,我使用 URI 連結到一個包含頁面資訊的 xml 文件,我需要後面的每個部分/test來連結到它

任何幫助將不勝感激,謝謝。

答案1

在設定中(無論是主 apache 設定或 vhosts 區塊)新增:

RewriteEngine on
RewriteRule "^/test/*" "/testhandler/" [PT]

分別。看:

https://httpd.apache.org/docs/2.4/rewrite/

https://httpd.apache.org/docs/2.4/rewrite/remapping.html

https://httpd.apache.org/docs/2.4/rewrite/flags.html

相關內容