How can I use Basic HTTP Authentication in PHP?

前端 未结 5 2030
心在旅途
心在旅途 2020-12-09 17:16

I\'m trying to use Basic HTTP Authentication and followed the example on the PHP manual page. But it doesn\'t work for me. The variable $_SERVER[\'PHP_AUTH_USER\']

5条回答
  •  一向
    一向 (楼主)
    2020-12-09 17:36

    I think the PHP methods rely on Basic Authentication being configured on the Web Server. An easy way to do this is to include a .htaccess file in the directory you want to enable basic authentication for.

    Most unix-based web hosts allow you to do this by just uploading this file. A separate file (call this .htauth) will hold the user logins that are allowed to access the site or directory.

提交回复
热议问题