简体   繁体   English

PHP重定向与HTTP身份验证

[英]Php redirect with http authentication

How to redirect to a url and pass through in php the login and password http, ie, the http basic login but without user interference? 如何重定向到url并在php中通过登录名和密码http,即http基本登录名而又不受用户干扰? without login pop-ups ! 没有登录弹出窗口!

thanks, celso 谢谢,塞尔索

Short answer is that you can't. 简短的答案是你不能。

Redirecting to http://user:pass@example.com/ will work on some browsers but not all. 重定向到http:// user:pass@example.com/可以在某些浏览器上工作,但不能在所有浏览器上工作。

You could use a substitute authentication module, and push a value into it - eg using mod_authmemcookie on Apache if you're happy to tweak the server config like this (and have a cookie you can use). 您可以使用替代身份验证模块,然后向其中推送一个值-例如,如果您愿意像这样调整服务器配置(并拥有一个可以使用的cookie),请在Apache上使用mod_authmemcookie

don't know if i understood you right, but if you only want to redirect to a http-auth-secured site without the annoying popup, you can sent the username and password in the url: 不知道我是否理解正确,但是如果您只想重定向到受HTTP身份验证保护的网站而没有烦人的弹出窗口,则可以在url中发送用户名和密码:

http://username:password@exapmle.com/adminpanel/

note that, with this solution, the password is readable in the url and some browsers (IE only <=6, this was disabled in the newer versions) don't support this - maybe thats a problem for you. 请注意,使用此解决方案,密码可以在url中读取,并且某些浏览器(IE仅<= 6,在新版本中已禁用)不支持此操作-也许这就是您的问题。 for more information, take a look at this article 有关更多信息,请查看本文

With basic auth, the browser will re-send credentials when requested by the server. 使用基本身份验证,浏览器将在服务器请求时重新发送凭据。 This only works for the same hostname though. 但是,这仅适用于相同的主机名。

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

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