正如我在主题中写的那样,我正在寻找通过AuthForm登录后将用户重定向到正确目的地的方法。
它应该看起来像那样:
用户在地址栏中输入地址addres domain.com/examplepage/something - >服务器将他重定向到domain.com/login.html(多数工作正常) - >登录后服务器将他重定向回domain.com/examplepage/something或用户输入的任何地址栏befor(那不工作:()
请求帮助,让我知道您的想法或现成的解决方案
在apache配置下(Debian上安装了Apache v2.4.10(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
告诉我您是否需要更多信息
感谢您的帮助:)
对不起英语; p
答案 0 :(得分:1)
好吧,我想我已经做到了。如果登录成功,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>
完成。花了两天时间搞清楚这一点。他们没有告诉你不同的模块对于相同的环境变量有不同的名称。他们也没有告诉您并非所有模块都可以同等地访问所有环境变量。是的,很多WTF时刻。