2010-12-16 102 views
0

我正在處理我的第一個網頁,我無法解決一個問題。我正在進行CMS維護設置。我想做出選擇(下拉)將索引從index.php更改爲maintenance.php。如何將我的網頁設置爲CMS的維護模式?

我的網站是這樣的:

/CMS/

的index.php

maintenance.php

如果我重新命名maintenance.php到index.php,CMS仍然有效(我離開登錄區管理員進入)。

所以,我的問題是:這是最合乎邏輯的方式切換到維護模式?如果是,那麼如何?或者也許有更有效的方法?

回答

0

創建一個打開和關閉維護模式(數據庫中爲零或一個)的表單域。然後,您可以在index.php html標記之前查詢該行。如果維護模式行返回1,則將用戶轉發到maintenance.php頁面。

<?php 
// query your database for the maintenance mode boolean 
if($maintenance == '1') header('Location: http://www.example.com/maintenance.php'); 
?> 
<html> 

或者,你可以做到這一切與index.php頁面和if/else語句:

</head> 
<body> 
<?php 
    // query your database for the maintenance mode boolean 
    if($maintenance == '1') include('maintenance.php'); 
    else{ 
?> 
<div id="homepage"> 
</div> 
<? } // end else ?> 
</body> 
+0

非常感謝你,有時候有些東西太簡單了,但對於某個人來說很難。 – 2010-12-17 01:53:43

0

爲什麼不把 '維護模式' 符號鏈接 'maintenance.php' 到'的index.php'?當你關閉它時,刪除符號鏈接並將'index.php'指向'realindex.php'