htaccess将网站置于维护状态,否认除了我自己的IP之外的所有内容 [英] htaccess put site into maintenance, deny all but my own IP
问题描述
我想把我的网页放到维护中,所以我用这个替换原来的htaccess文件:
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
在发布之前已经阅读了很多帖子,这是我收集的将是正确的解决方案,但我不能让它工作。如果我不允许使用我自己的IP,我会收到错误500(这意味着我的访问者会看到),如果我使用我的IP,我会得到错误403(我甚至没有到达我的维护页面,这就是我那里也不允许。)
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.
推荐答案
找到适合我的解决方案。
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]
这篇关于htaccess将网站置于维护状态,否认除了我自己的IP之外的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!