2011-03-06 81 views

回答

1

如果你使用Apache,我會建議使用此:

http://httpd.apache.org/docs/2.0/mod/mod_actions.html

這可能不是最好的方法,但它的工作原理FO我。

基本上你會設置一個腳本,Apache將發送所有請求。

# Files of a particular file extension 
AddHandler handler .html 
Action handler /handler.php 

每次請求html文件時,Apache都會運行handler.php。

handler.php裏面,您可以使用$_SERVER來確定請求的文件,檢查它是否存在,如果它退出,請將其包含在內。如果它不存在,請做你需要做的事情。

+0

thans凱爾這是有用的我的其他問題:D – 2011-03-06 02:42:12

+0

不客氣。它可能只是創建一個自定義的404錯誤文檔,做你所需要的,但我沒有嘗試過。 'ErrorDocument 404/whatever_you_need_to_show' – Kyle 2011-03-06 02:44:01

1

服務於一個頁面,如果存在其他服務另一種,以下內容添加到您的.htaccess文件,

Options +FollowSymLinks -MultiViews 

RewriteEngine On 
RewriteRule .+ - [L] 

# serve file if exists 
RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f 
RewriteRule ^(.*)$ /cache/index.html [L,QSA] 

# else serve other file 
RewriteCond %{DOCUMENT_ROOT}/cache/index.html !-f 
RewriteRule ^(.*)$ /index.html [L] 

不要忘了這個工作,你應該有的AllowOverride在您的虛擬主機的所有文件。

相關問題