重定向至使用.htaccess密码的页面


Redirect to page with .htaccess password

是否可以将"人员"重定向到受密码.htaccess.保护的网站上的文件夹

可能通过使用php或其他方式,而不是"http://user:pwd@网站"方式"

还是最好只编写这些受保护区域的文件夹/文件视图的脚本。

大多数浏览器都会对嵌入的用户名/密码发出警告,因为垃圾邮件发送者传统上会滥用这种链接,将他们的阴茎药丸URL隐藏在"正常外观"的链接后面。

如果您想进行自动登录,请使用某种加密令牌重定向,受保护的网站可以解密该令牌,并据此授予/拒绝访问权限。

赤裸裸的形式:

$raw_token = array('username' => 'joe', 'password' => '123', 'coming_from' => 'yoursite.com');
$crypted_token = base64_encode(do_some_encryption(json_encode($raw_token), 'the passphrase'));
header("Location: http://othersite.com?token=$crypted_token")

然后在接收端:

$crypted_token = $_GET['token'];
$raw_token = json_decode(do_some_decryption(base64_decode($crypted_token), 'the passphrase'));
$username = $raw_token['username'];
$password = $raw_token['password'];
do_login($username, $password);