htaccess put site into maintenance, deny all but m

2019-02-16 04:23发布

问题:

I want to put my webpage into maintenance so I replace my original htaccess file with this:

ErrorDocument 403 /maintenance/maintenance.php
order deny,allow
deny from all
allow from 111.222.333.444

Have read a lot of threads before posting and this is what i gathered would be the correct solution, but I don´t get it to work. If I don´t allow from my own IP I get an Error 500 (meaning that that is what my visitors would see) and if I do use my IP I get and Error 403 (and I dont even reach my maintenance page it sais I´m not allowed there either).

What am I doing wrong here? Thanks in advance.

回答1:

Found the solution that worked for me.

RewriteEngine On
RewriteBase /

#ip is not your ip. Change ip to see maintenance page
RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.444$

#requests made not to maintenance.php ... 
RewriteCond %{REQUEST_URI} !^/maintenance\.php$

#rewrite to maintenance.php
RewriteRule ^(.*)$ /maintenance.php [L]


回答2:

The .htaccess you posted works for me with Allow from 127.0.0.1, but you need an additional .htaccess in the maintenance directory, allowing access to the maintenance.php error document

Order allow,deny
Allow from all


回答3:

Try my tips, paste this code into the .htaccess of your site, to make all the pages of your domain remapping into /maintenance.html file, if the viewer's I.P. isn't the same as yours:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REMOTE_ADDR} !^000\.111\.222\.333
RewriteCond ^(.*) /maintenance.html

Keep noted that the numbers 000\.111\.222\.333 must be changed as your I.P. address, and create a /maintenance.html file where your pages will be remapped.



标签: .htaccess ip