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
I define firewall rules that make all the visits to port 80 (HTTP), fall into a captive portal/a FreeBSD server with an Apache daemon. portal.html is a WISPr tagged HTML page.
I defined the relevant Apache configuration as:
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
It is not working quite right, as the CNA browser enters a redirect loop.
I also tried putting all my relevant pages into a /captive directory, and defining the rule
RewriteRule !^captive($|/) http://192.168.2.1/captive/portal.html [L,R=302]
But had similar loop problems. What to do?