I have been trying to build a captive portal in Apache that I plan to be Apple CNA aware.
I found several relevant posts in StackOverflow, including Captive portal popups... and How to create WiFi popup login page.
我将相关的 Apache 配置定义为:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^CaptiveNetworkSupport(.*)$ [NC]
RewriteRule ^(.*)$ http://192.168.2.1/captive/portal.html [L,R=302]
# android
RedirectMatch 302 /generate_204 http://192.168.2.1/captive/portal.html
# windows
RedirectMatch 302 /ncsi.txt http://192.168.2.1/captive/portal.html
Run Code Online (Sandbox Code Playgroud)
它工作不完全正确,因为 CNA 浏览器进入重定向循环。
我还尝试将所有相关页面放入 /captive 目录,并定义规则
RewriteRule !^captive($|/) http://192.168.2.1/captive/portal.html [L,R=302]
Run Code Online (Sandbox Code Playgroud)
但有类似的循环问题。该怎么办?
apache-httpd ×1