Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache .htaccess在IP地址或用户凭据不匹配时重定向_Apache_.htaccess_Redirect - Fatal编程技术网

Apache .htaccess在IP地址或用户凭据不匹配时重定向

Apache .htaccess在IP地址或用户凭据不匹配时重定向,apache,.htaccess,redirect,Apache,.htaccess,Redirect,这是我当前的.htaccess文件。如果IP地址或用户凭据不匹配,它将限制对目录的访问 我想知道,如果未经授权的用户输入了错误的用户名/密码或不是来自允许的IP地址,如何将其重定向到另一个非文件网站,例如www.google.com 我尝试添加401重定向,例如ErrorDocument 401 www.google.com,但似乎不起作用 Options +FollowSymLinks RewriteEngine On RewriteBase / # Define IP Address Se

这是我当前的.htaccess文件。如果IP地址或用户凭据不匹配,它将限制对目录的访问

我想知道,如果未经授权的用户输入了错误的用户名/密码或不是来自允许的IP地址,如何将其重定向到另一个非文件网站,例如www.google.com

我尝试添加401重定向,例如ErrorDocument 401 www.google.com,但似乎不起作用

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

# Define IP Address
SetEnvIf Remote_Addr "^123\.123\.123\.1$" IsIntern

# Authentication
AuthUserFile /.htpasswds/public_html/home/passwd
AuthName "Website Protected"
AuthType Basic
require valid-user
Order allow,deny
Allow from env=IsIntern
satisfy any

您不能在401自定义处理程序中使用完整URL。Apache将在日志中抛出此错误:

cannot use a full URL in a 401 ErrorDocument directive --- ignoring!
相反,您可以:

ErrorDocument 401 /handle401.html
从handle401.html,您可以使用Javascript重定向到任何其他网站