apache .htaccess 替代“deny from XXXX”?
我有 nginx 反向代理到 apache,如果我将“拒绝来自 111.111.111.111”添加到我的 htaccess,它仍然允许它们通过,因为 nginx 不会转发访问者的 remote_addr ip。
是否有规则或其他内容可以添加到 htaccess,以便如果访问者 IP 地址使用“HTTP_X_REAL_IP”,我可以将它们重定向到静态 html 页面?
I have nginx reverse proxying to apache and if I add "Deny from 111.111.111.111" to my htaccess it still allows them through as nginx doesn't forward the remote_addr ip of the visitor.
Is there a rule or something I can add to htaccess so if an the visitors ip address using "HTTP_X_REAL_IP" I can just redirect them to a static html page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西应该有效:
重写规则将向他们发送 403 禁止响应,而不替换另一个 url。这应该会导致显示默认的 403 错误页面。
您可以使用以下方法指定 403 错误页面:
请参阅: http://httpd .apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond 和 http://httpd.apache.org/docs/2.0/mod/core.html#errordocument 了解更多信息。
Something like this should work:
That rewrite rule will send them a 403 forbidden response without substituting another url. This should cause your default 403 error page to be shown.
You can specify your 403 error page using this:
see: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond and http://httpd.apache.org/docs/2.0/mod/core.html#errordocument for more info.