문제

아래의 각 규칙은 단독으로 사용될 때 잘 작동합니다. 그러나 함께 사용하면 규칙의 행동이 변경됩니다.

규칙 세트 # 2 자체를 사용하는 경우 https : // 내부/보안/로그인 브라우저의 지식없이 Apache가 Sapphire/Main.php로 다시 작성합니다. 이것이 예상되는 행동입니다.

두 규칙 세트가 모두 함께 사용될 때, 이전에 언급 된 URL에 대한 요청은 Apache가 301 리디렉션을 보내는 것을 보냅니다. http : //internal/sapphire/main.php? url = 보안/로그인.

Apache가 내부 재 작성 대신이 리디렉션을 보내는 이유는 무엇입니까?

# Rule Set # 1
# - Forces all HTTPS requests to HTTP, except for security section requests.
#   Example: request for https://internal/abc/ 
#   -> redirected to http://internal/abc/
RewriteCond %{SERVER_PORT} =443
RewriteCond %{REQUEST_URI} !^/Security($|/.*$)
RewriteRule (.*) http://internal/$1 [R=301,L]

# Rule Set # 2
# - Hands request to CMS - web user does not see this behind-the-scenes rewrite
RewriteRule (.*) sapphire/main.php?url=$1&%{QUERY_STRING} [L]
도움이 되었습니까?

해결책

그만큼 플래그는 이미 다시 작성된 URL을 다시 주입합니다. 따라서 대신 원래 요청 된 URL을 분석하십시오.

RewriteCond %{SERVER_PORT} =443
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /Security[/?\ ]
RewriteRule (.*) http://internal/$1 [R=301,L]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top