I solved my own question based on: https://serverfault.com/questions/679393/captive-portal-popups-the-definitive-guide
iOS and OSX devices make a request to a URL to detect captive portals. The rules are the following:
- GET/POST http://foo.com/bar.html
- If bar.html == [expected content] > Open Internet
- If bar.html != [expected content] > Captive Portal
- If bar.html[status] != SUCCESS > No Network
However, I was redirecting users using an HTTP header when they first hit the captive portal. This does not fall into any of the above rules and therefore prevented Apple devices from detecting that there was a captive portal.
Here is my final code, which redirects to my portal from a weird URL that the hotspot gives:
<?php
/* Trying to get Apple to show the WiFi popup */
if (!empty($_REQUEST['url']) && (strstr($_REQUEST['url'],'success.html') || strstr($_REQUEST['url'],'detect.html'))) {
echo '
Redirecting...
<script type="text/javascript">
window.location = "/index.html";
</script>';
exit;
}
header("Location:/index.html?". $_SERVER['QUERY_STRING']);
As you can see, Apple devices need to see some actual content, not a redirect.
I also rewrite the .php file extensions as .html.
Hope this helps somebody else.