2015-05-14 94 views
1

我的維護頁面到我的網站有一個相當奇怪的故障,頁面重定向,但在htaccess代碼中的東西阻止了CSS和JavaScript文件。請看看我的代碼裏面有些東西不太正確,因爲5當我刪除重定向時,CSS正常加載。重定向到維護頁問題

# 
# Redirection to the Maintenance Page 
RewriteCond %{REMOTE_ADDR} !^25\.210\.157\.0 
RewriteCond %{REQUEST_URI} !/maintenance.html$ 
RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|png|gif) 
RewriteRule .* /maintenance.html [R=307,L] 
# 
# 

找到了答案,但有沒有更簡單的方法,而不是選擇所有類型的文件全包圍命令?

RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|png|gif|css|js|ico|woff|eot|svg|ttf) 

回答

1

您可以使用:

RewriteCond %{REMOTE_ADDR} !^25\.210\.157\.0 
RewriteCond %{REQUEST_URI} !/maintenance\.html$ [NC] 
# If the request is not for a valid directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# If the request is not for a valid file 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule .* /maintenance.html [R=307,L] 
+1

感謝anubhava,做同樣的工作,但乾淨。 –