方法極簡單:修改 Apache httpd.conf,在 AddType 區段新增一行,重啟 Apache 即可讓 .asp 檔案由 PHP 引擎解析。
# If the AddEncoding directives above are commented-out, then you # probably should define those extensions to indicate media types: # AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php AddType application/x-httpd-php .php3 AddType application/x-httpd-php .asp
新增最後一行 AddType application/x-httpd-php .asp 即可。此技巧常用於:
注意: 此設定僅影響 Apache 對副檔名的處理器對應,.asp 檔案內容必須符合 PHP 語法,原本的 ASP (VBScript) 代碼將無法執行。