2012-07-30 20 views
0

我正在使用.htaccess重定向和HTML meta刷新的組合以便在從備份還原網站時放入臨時初始頁面。HTML元刷新 - 刪除文件後的錯誤

這裏的index.html

<!DOCTYPE html> 
<html> 
    <head> 
     <title>Site Restore</title> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <meta http-equiv="refresh" content="15"> 
     <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?3.5.1/build/cssreset/cssreset-min.css&3.5.1/build/cssfonts/cssfonts-min.css&3.5.1/build/cssbase/cssbase-min.css"> 
     <style type="text/css"> 
      html { 
       background-color: #ccc; 
      } 
      div { 
       margin: 1em auto; 
       border: 1px solid #000; 
       border-radius: 0.5em; 
       padding: 1em; 
       width: 480px; 
       background-color: #fff; 
      } 
     </style> 
    </head> 
    <body> 
     <div> 
      <h1>Site Restore</h1> 
      <p>This web site is being restored from a back-up, and will be back online shortly.</p> 
      <p>If you leave this page open, it will redirect when the site restore is complete.</p> 
     </div> 
    </body> 
</html> 

.htaccess重定向:

RewriteEngine On 
RewriteBase/
RewriteRule ^.+$/[R=302,NC,L] 

備份後恢復完成後,我從.htaccess刪除RewriteRule ^.+$/[R=302,NC,L]線和刪除index.html文件。儘管index.html不在URL,我得到這個錯誤從Web服務器返回:

故宮

您沒有權限訪問此服務器上/index.html。 的Apache/2.2服務器在dev.swissmangocms.com端口80

如果我手動刷新瀏覽器窗口,index.php如我所期望的加載。我如何避免錯誤消息和手動步驟?

+1

聽起來像一個瀏覽器緩存問題 – 2012-07-30 14:49:56

+0

@JonLin - 這是有道理的,但我該如何克服它? – Sonny 2012-07-30 14:51:14

回答

1

Jon Lin的評論讓我看到禁用瀏覽器緩存的方向。我發現了另一個職位上如此,「Using tags to turn off caching in all browsers?」,並添加這些行我index.html<head>部分:

<meta http-equiv="cache-control" content="max-age=0"> 
<meta http-equiv="cache-control" content="no-cache"> 
<meta http-equiv="expires" content="0"> 
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"> 
<meta http-equiv="pragma" content="no-cache"> 

那固定的錯誤!