htaccess put site into maintenance, deny all but my own IP [closed]

不羁的心 提交于 2019-12-30 07:41:32

问题


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.



来源:https://stackoverflow.com/questions/15817783/htaccess-put-site-into-maintenance-deny-all-but-my-own-ip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!