2017-04-07 2 views
1

필자는 화제로 인해서 AuthForm을 통해 로그인 한 후 적절한 목적지로 사용자를 리디렉션하는 방법을 찾고 있습니다.AuthFormLoginLocation에서 로그인 한 후 이전 페이지로 리다이렉트 [Apache2 configuration]

그것은 외모는 그런 식으로 떨어지게한다 : 주소 표시 줄 요지에

사용자 입력이 domain.com/examplepage/something - 로그인 후> -> 서버가 그 (그게 전부가 잘 작동) domain.com/login.html 리디렉션 서버는 사용자가

탄원 도움 (그 밤은이 :(일)을 befor 주소 표시 줄에 입력 한 어떤 domain.com/examplepage/something하거나 그를 다시 리디렉션, 나를 당신의 아이디어 나

아래 준비 솔루션에 대해 알려 아파치 설정 (데비안에 설치된 아파치 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 [email protected] 
    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 
당신은 도움을

감사합니다 :) 영어

죄송 자세한 정보가 필요하면 말해, 나는 그것을 한 적이 생각

+0

내가 너무 이것에 대한 해결책을 모색하고있다. 나는 PHP로 할 수 있다는 것을 알고 있지만, 나는 로그인 페이지를 위해서만 PHP를 소개하는 것을 선호하지 않는다. 지금 당장 mod_rewrite가이 작업을 수행 할 수 있다고 생각합니다. 아직도 세부 사항을 모으고 있습니다. –

답변

0

좋아 쪽. 로그인이 성공하면 이전 페이지로 사용자를 되돌리기위한 100 % Apache 구현.

준비는 다음 reference에 설명 된대로

  • 나는 독립 로그인 방식을 사용합니다.
  • 로그인 양식 동작은 /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> 

완료 (I 만 라인을 추가 할 목록 해요) 세 줄을 추가합니다. 이것을 알아 내기 위해 이틀을 보냈습니다. 그들은 다른 모듈이 동일한 환경 변수에 대해 다른 이름을 가지고 있다고 말하지 않습니다. 또한 모든 환경 변수가 모든 모듈에 동등하게 액세스 할 수있는 것은 아니라고 말하지 않습니다. 네, 많은 WTF 순간.

추가 참조 : 1, 23