Can I login to a protected directory via a link?

不羁的心 提交于 2019-12-08 14:32:02

问题


I want to create links to pages and content that are in protected directories. I didn't program the protected directories I set them up from the host admin page.

I want to be able to give links to user that will take them to page and login as well.

Also if there is a way I want to be able to embed content from the protected directories in other places and not have the password box shop up in order to display the content.

I am using PHP4

Thanks!


回答1:


Depending on the authentication, you can use a URL like this:

http://username:password@yoursite.com/protected_dir

I know that works for simple protection via .htaccess. However, keep in mind that you will be sending that link with the password in clear text, and may be inadvertently seen by the wrong people.




回答2:


Also if there is a way I want to be able to embed content from the protected directories in other places and not have the password box shop up in order to display the content.

Read it with fsockopen. Here's an example od fsockopen with basic authentication http://pl.php.net/manual/en/function.fsockopen.php#32830




回答3:


...I want to be able to embed content from the protected directories in other places and not have the password box shop up in order to display the content.

As a direct link this

http://username:password@yoursite.com/protected_dir/file.html

does not work, but only when attempting to see it with IE browser I think if you want to embed contents via PHP you might use this:

file_get_contents("http://username:password@yoursite.com/protected_dir/file.html")

If you try this one, plz let me know, i'm interested too.



来源:https://stackoverflow.com/questions/738188/can-i-login-to-a-protected-directory-via-a-link

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!