Skip to content

Instantly share code, notes, and snippets.

@malle-pietje
Last active December 14, 2023 06:34
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save malle-pietje/c030e9d6ccdc1c3ddfdfc4363ba79489 to your computer and use it in GitHub Desktop.
Save malle-pietje/c030e9d6ccdc1c3ddfdfc4363ba79489 to your computer and use it in GitHub Desktop.
Redirection to a custom URL from the UniFi controller JSP-based captive portal
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<title><unifi txt="Redirector" /></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="refresh" content="0;url=https://<YOUR CAPTIVE PORTAL URL>/<unifi var="mac" />/<unifi var="ap_mac" />">
</head>
<body>
</body>
</html>
@malle-pietje
Copy link
Author

malle-pietje commented Jul 31, 2019

UBNT now actively support the AngularJS portal but the Legacy JSP portal is still available, so the method described here still works fine. It also prevents the encoded parameters (ec) from showing up, if that is an issue for your external portal I suggest you take this approach.
With our captive portal platform the ec parameter is automatically decoded so we can choose from both methods and use each of them as needed.

@Maxwellkurt0407
Copy link

Maxwellkurt0407 commented Oct 3, 2019

I've tried to the above mentioned index.html

But this is the result of the redirected link:
/portal/

I cannot get the mac address of the guest/client that connects.

@malle-pietje
Copy link
Author

I've tried to the above mentioned index.html

But this is the result of the redirected link:
/portal/

I cannot get the mac address of the guest/client that connects.

This is not the expected result. Did you make sure not to use a Windows editor if your controller is running on Linux? Can you also confirm which guest control settings you changed?

@Maxwellkurt0407
Copy link

I've tried to the above mentioned index.html
But this is the result of the redirected link:
/portal/
I cannot get the mac address of the guest/client that connects.

This is not the expected result. Did you make sure not to use a Windows editor if your controller is running on Linux? Can you also confirm which guest control settings you changed?

Sorry for responding late. I have settled the problem the had single quotes instead of double quotes.
Thank you for your response to the earlier query.

@malle-pietje
Copy link
Author

That does make sense, thanks for the feedback.

@Maxwellkurt0407
Copy link

image
Should the settings of the controller be like this?

@Maxwellkurt0407
Copy link

Can this code be used if the unifi controller is being hosted online, cloud?

@vettorazi
Copy link

@malle-pietje Thank you so much for your help! <3

@malle-pietje
Copy link
Author

@malle-pietje Thank you so much for your help! <3

You’re welcome 👍

@CumpsD
Copy link

CumpsD commented Dec 13, 2023

FYI legacy hotspot seems to be completely gone from Network 8.0.24, only the Angular seems to be left

@malle-pietje
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment