自动htaccess登录 - 从一次登录访问多个受保护的目录

时间:2022-01-30 08:49:08

I am trying to make a php login page that allows users to access multiple .htaccess protected pages (on apache server). So a user would enter a password in a form on page 1 and depending on which login they provided, they would be sent to one directory or another, but I want the login to happen automatically to the subsequent pages (login is only required on page 1). How does one go about auto logging into an htaccess page if the proper credentials are provided on a referring page? I don't want to append credentials in the url ?user=user&pass=pass

我正在尝试创建一个允许用户访问多个.htaccess受保护页面的php登录页面(在apache服务器上)。因此,用户可以在第1页的表单中输入密码,并根据他们提供的登录信息,将它们发送到一个目录或另一个目录,但我希望登录自动发生在后续页面中(仅在页面上需要登录) 1)。如果在引用页面上提供了正确的凭据,如何自动登录到htaccess页面?我不想在url?user = user&pass = pass中附加凭据

2 个解决方案

#1


1  

If you use multiple .htaccess files be sure to set the AuthName the same. This tells the browser that the same cached uid/password should be provided for that "Realm".

如果您使用多个.htaccess文件,请确保将AuthName设置为相同。这告诉浏览器应该为该“Realm”提供相同的缓存uid /密码。

#2


0  

If the other pages are in the same directory or below most browsers will keep sending the same credentials for subsequent requests if you have the same .htaccess-rules for all the files/directories.

如果其他页面位于同一目录或下面,如果您对所有文件/目录具有相同的.htaccess-rules,则大多数浏览器将继续为后续请求发送相同的凭据。

Another alternative to passing ?user=user&pass=pass would be to use POST instead of GET to sendt this request (if you are passing on from a form that is).

传递?user = user&pass = pass的另一种方法是使用POST而不是GET来发送此请求(如果您从表单传递)。

#1


1  

If you use multiple .htaccess files be sure to set the AuthName the same. This tells the browser that the same cached uid/password should be provided for that "Realm".

如果您使用多个.htaccess文件,请确保将AuthName设置为相同。这告诉浏览器应该为该“Realm”提供相同的缓存uid /密码。

#2


0  

If the other pages are in the same directory or below most browsers will keep sending the same credentials for subsequent requests if you have the same .htaccess-rules for all the files/directories.

如果其他页面位于同一目录或下面,如果您对所有文件/目录具有相同的.htaccess-rules,则大多数浏览器将继续为后续请求发送相同的凭据。

Another alternative to passing ?user=user&pass=pass would be to use POST instead of GET to sendt this request (if you are passing on from a form that is).

传递?user = user&pass = pass的另一种方法是使用POST而不是GET来发送此请求(如果您从表单传递)。