如何使用htaccess为整个网站设置维护模式

ipe*_*pel 1 .htaccess maintenance offline

我发现这个代码用于htaccess禁用整个网站(用于维护模式):

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/offline.php$
RewriteRule .* /offline.php [R=307,L]
Run Code Online (Sandbox Code Playgroud)

现在在我的offline.php页面中,我有一个指向css和js文件的链接,例如:

<link rel="stylesheet" href="include/css/error.css">
<script src="include/js/file.js"></script>
Run Code Online (Sandbox Code Playgroud)

当我使用上面的代码设置维护模式时,加载了offline.php页面,但没有css和js,我如何允许加载这两个文件?

并且我认为除了我的ip之外禁用所有人的网站是有用的,这样我可以更新网站,这是可能的吗?

Nav*_*vin 6

我找到一个包含您的问题答案的博客请查看此网站

以下实例取自上述的组织部位.

如果您的域的根目录中还没有.htaccess文件,请创建一个并添加以下代码.如果您已有.htaccess文件,请在可能存在的所有内容之前添加以下代码

RewriteEngine On

# Add all the IP addresses of people that are helping in development
# and need to be able to get past the maintenance mode.
# One might call this the 'allow people list'
RewriteCond %{REMOTE_HOST} !^83\.101\.79\.62
RewriteCond %{REMOTE_HOST} !^91\.181\.207\.191

# Make sure the maintenance mode only applies to this domain
# Example: I am hosting different sites on my server
# which could be affected by these rules.
RewriteCond %{HTTP_HOST} ^nocreativity.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.nocreativity.com$

# This is the 'ignore file list'. It allows access to all
# files that are needed to display the maintenance mode page.
# Example: pages, css files, js files, images, anything.
# IMPORTANT: If you don't do this properly, visitors will end up with
# endless redirect loops in their browser.
RewriteCond %{REQUEST_URI} !/offline\.htm$
RewriteCond %{REQUEST_URI} !/css\/style\.css$
RewriteCond %{REQUEST_URI} !/images\/logo\.png$

# Rewrite whatever request is coming in to the maintenance mode page
# The R=302 tells browsers (and search engines) that this
# redirect is only temporarily.
# L stops any other rules below this from executing whenever somebody is redirected.
RewriteRule \.*$ /offline.htm [R=302,L]
Run Code Online (Sandbox Code Playgroud)