您好我的.htaccess重定向到我的maintenance.html页面时遇到问题。有人可以帮帮我吗。这是我的示例代码.htaccess
<Limit GET POST PUT>
order deny,allow
deny from all
allow from 123.456.789
allow from 123.456.789
</LIMIT>
ErrorDocument 403 /maintenance.html
<Files maintenance.html>
order allow,deny
allow from all
</Files>
我有500个内部服务器错误。
答案 0 :(得分:0)
你很亲密。如果请求是针对图像的,那么您需要的是防止重定向的条件。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=xxx.xxx.xxx.xxx
RewriteCond %{REMOTE_ADDR} !=127.0.0.1
RewriteCond %{REQUEST_URI} !/maintenance\.html
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^.*$ http://localhost/blabla/maintenance.html [R=302,L]
</IfModule>
答案 1 :(得分:0)
这对我有用!请在根目录中放入maintenance.html。
##
# Maintenance page
##
<IfModule mod_rewrite.c>
RewriteEngine On
# local ip
RewriteCond %{REMOTE_ADDR} !^222.222.333
# server ip
RewriteCond %{REMOTE_ADDR} !^111.222.333
# maintenance page and assets
RewriteCond %{REQUEST_URI} !/maintenance [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
# serve default 503 response
RewriteRule ^(.*)$ maintenance.html [R=503,L]
</IfModule>
# serve custom 503 response
ErrorDocument 503 /maintenance.html
<IfModule mod_headers.c>
Header always set Retry-After "86400"
</IfModule>