已解决
我的问题是如何密码保护文件夹,以及文件(页面)。它只允许我对文件夹进行密码保护,我要么希望能够像php功能一样使用它重定向到登录页面,如果你转到它,并且我设置的当前密码/用户名是正确的,那么它会再次将你重定向回到最初受保护的页面,要么只是使用一个我不知道的简单功能将其重定向到登录页。
我已经尝试过的东西
- x10Hosting提供的重定向功能
- 无法使用,因为返回会自动将其重定向回登录页面;从而导致无限循环
- 将其放入文件夹并从中访问
- 我有一个秘密页面,介绍即将到来的活动和项目,隐藏页面,还有更多的老师和同学。密码保护文件夹只会通过查看索引来访问它,而他们都没有能力或智慧来了解如何操作。另外,我必须创建一个单独的FTP帐户,他们也不知道如何操作
需要注意的事项
- 我曾经有一个系统,它使用.aspx扩展页面,在
login.aspx
页面和secret.aspx
页面本身的<html>
之前都有一个<? ?>
(我认为是php)打开/关闭标记,但现在从我的旧web主机迁移到x10Hosting,它将.aspx文件作为文本文档读取,导致它在加载时以文本文档的形式打开,所以我不能使用我认为(是唯一一个)不支持<?
标签的.aspx扩展,导致它只显示为页面上方的文本。从那以后,我丢失了那个代码 - 我希望它能够在一个单独的页面上有一个简单的登录表单,而直接进入秘密页面会将其重定向到
login.?
页面,您可以在其中输入密码&我设置的用户名,如果正确的话,我认为点击按钮(<input type="submit">
)会自动将您重定向到秘密页面
已解决;想通了
在@Ohgodhwhy的帮助下,我设法恢复了我的旧系统。使用PhP,我使用以下代码作为我的秘密页面;
<%
Validated = "OK"
if Request.Cookies("ValidUser") <> Validated then
'Construct the URL for the current page.
dim s
s = "http://"
s = s & Request.ServerVariables("HTTP_HOST")
s = s & Request.ServerVariables("URL")
if Request.QueryString.Count > 0 THEN
s = s & "?" & Request.QueryString
end if
'Redirect unauthorized users to the logon page.
Response.Redirect "Logon.asp?from=" &Server.URLEncode(s)
End if
%>
<html>
...
</html>
然后我使用以下代码登录页面;
<%
Username="[insert]"
Password="[insert]"
Validated = "OK"
if Strcomp(Request.Form("User"),Username,1)=0 AND Request.Form("password") = Password then
'Set the validation cookie and redirect the user to the original page.
Response.Cookies("ValidUser") = Validated
'Check where the users are coming from within the application.
If (Request.QueryString("from")<>"") then
Response.Redirect Request.QueryString("from")
else
'If the first page that the user accessed is the Logon page,
'direct them to the default page.
Response.Redirect "secret.aspx"
End if
Else
' Only present the failure message if the user typed in something.
If Request.Form("User") <> "" then
Response.Write "<h3>Authorization Failed.</h3>" & "<br>" & _
"Please try again.<br> <br>"
End if
End if
%>
...
<div id="body">
<form action=<%Response.Write "LogonSecurity.asp?"&Request.QueryString%> method="post">
<h3>Login</h3>
<p>
Username:
<input type="text" name="User" placeholder="Username" value='' size="20"></input>
Password:
<input type="password" name="password" placeholder="Password" value='' size="20"></input>
<input type="submit" value="Logon"></input>
</form>
</div>
...
</html>