Apache .htaccess在IP地址或用户凭据不匹配时重定向
这是我当前的.htaccess文件。如果IP地址或用户凭据不匹配,它将限制对目录的访问 我想知道,如果未经授权的用户输入了错误的用户名/密码或不是来自允许的IP地址,如何将其重定向到另一个非文件网站,例如www.google.com 我尝试添加401重定向,例如ErrorDocument 401 www.google.com,但似乎不起作用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
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重定向到任何其他网站