基于IP mod_rewrite的 [英] mod_rewrite based on ip

查看:167
本文介绍了基于IP mod_rewrite的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现的mod_rewrite把我的网站进入维持性。基本上,除了我们指定了一把所有IP将被转发到一个静态的HTML页面。

I'd like to implement mod_rewrite to put my site into maintance. Basically all ips except a handful we specify would be forwarded to a static html page.

请有人可以帮助这条规则。也就是有办法把这个和关闭不容易的编辑工作htaccess文件?

Please can someone help with this rule. Also is there a way to turn this on and off easily without editting the htaccess file?

谢谢, 约什

推荐答案

您可以使用 REMOTE_ADDR在的RewriteCond 变量

RewriteCond %{REMOTE_ADDR} !^10\.0\.1\.1$
RewriteRule ^ /maintenance.html

只要改变条件来匹配你想要的IP地址,一个以上的可以使用^(IP1 | IP2 | ... | IPN)$。

Just change the condition to match the IPs you want, for more than one you can use ^(ip1|ip2|...|ipn)$.

有关如何禁用维护模式不改变.htaccess文件,我认为这是不可能的短写一个程序,将其删除或修改它,一个容易将其重命名。

About how to disable the maintenance mode without changing the .htaccess file I think that's not possible short of writing a program that would delete it or otherwise modify it, an easy one would be to rename it.

这篇关于基于IP mod_rewrite的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆