简体   繁体   English

如何将所有拒绝的域名重定向到htaccess中的另一个页面?

[英]How can i redirect all denied domain name to another page in htaccess?

i use htaccess file to deny all requests to any page and allow only access from a list of some domain names. 我使用htaccess文件拒绝对任何页面的所有请求,并且仅允许从某些域名列表中进行访问。 But i wish to redirect all denied domain names to another local page. 但是我希望将所有拒绝的域名重定向到另一个本地页面。

I wrote this in my htaccess file : 我在htaccess文件中写了这个:

# intercept request
RewriteEngine On
<Files "mypage.php">
    Order deny,allow
    Deny from all
    #Allow from 197.149.16.181
    Allow from .*domain1\.com.*
    Allow from .*domain2\.com.*
</Files>

ErrorDocument 404 ../you_are_not_authorised.html

But when a denied domain name or denied ip is opening the file, server still show its default 404 error page ><. 但是当拒绝域名或拒绝IP打开文件时,服务器仍显示其默认的404错误页面> <。

What have i omitted to do please? 我省略了什么呢?

To show a custom page for denied requests you need to use ErrorDocument 403 handler. 要显示拒绝请求的自定义页面,您需要使用ErrorDocument 403处理程序。

ErrorDocument 403 /you_are_not_authorised.html

It is advisable to give full path your custom error page that starts with / . 建议您提供以/开头的自定义错误页面的完整路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM