正如我在主题中所写,我正在寻找通过 AuthForm 登录后将用户重定向到正确目的地的方法。
它应该看起来像这样:
用户在地址栏中输入地址 domain.com/examplepage/something -> 服务器将他重定向到 domain.com/login.html(这工作正常)-> 登录后服务器将他重定向回 domain.com/examplepage/something 或其他任何用户之前已经输入地址栏(这不起作用:()
请帮忙,让我知道您的想法或现成的解决方案
下面的 apache 配置(Apache v2.4.10 安装在 Debian (Raspbian - Jessie) 上)
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html">
AuthFormProvider file
AuthType form
AuthName "Reserved Area"
AuthFormLoginRequiredLocation /login.html
Session On
SessionCookieName session path=/
require valid-user
AuthUserFile /etc/apache2/.htpasswd
</Directory>
<Location "/login.html">
Order allow,deny
Allow from all
Require all granted
</Location>
Alias /open/ "/var/www/open/"
<Directory "/var/www/open/">
Order allow,deny
Allow from all
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
Run Code Online (Sandbox Code Playgroud)
告诉我您是否需要更多信息
感谢帮助 :)
对不起英语;p
小智 5
好吧,我想我已经做到了。100% Apache 实现,用于在登录成功时将用户返回到上一页。
准备工作:
/dologin./test/。现在添加三行(我只列出要添加的行)
<Directory var/www/html/test>
# Set a fake query parameter for redirecting if auth successful
AuthFormLoginRequiredLocation /login.html?req=%{REQUEST_URI}
</Directory>
<Location /dologin>
# Put this at the bottom of the block, maybe.
# Extract request before interrupt and redirect
SetEnvIf Referer ^.*req=(.*)&?$ req=$1
AuthFormLoginSuccessLocation %{ENV:req}
</Location>
Run Code Online (Sandbox Code Playgroud)
完毕。花了两天时间才弄明白。他们不会告诉您,对于相同的环境变量,不同的模块具有不同的名称。它们也不会告诉您并非所有模块都可以同等访问所有环境变量。是的,很多 WTF 时刻。
| 归档时间: |
|
| 查看次数: |
1391 次 |
| 最近记录: |