Redirecting Users
Knocknoc supports two ways to redirect the user to a specific site from the Knocknoc Dashboard. The first way is to redirect from a parameter in the URL used to access the Dashboard, the second is to have a user automatically redirect when logging in with a single Knoc.
Redirecting to a Referrer URL
This is the most basic way to redirect users to a custom URL from the Knocknoc Dashboard. To achieve this, simply add the referrer query parameter to the link used to access Knocknoc, for example: https://my.example.knocknoc.com?referrer=https://my.website.com
Note: The referrer link will only be redirected to if the user has a Knoc with a URL matching the same base as the referrer.
This can be useful as a static redirect, or it can also be dynamic, depending on your firewall configuration.
For example, if this Javascript is used on your redirect page, then once the user is authenticated with Knocknoc they will be sent back to the page they were trying to access.
<script>
const baseUrl = 'knocknoc.mycompany.com';
setTimeout(() => {
const currentUrl = document.URL;
if (!currentUrl || !baseUrl) return;
try {
// Add https:// if the URL doesn't already have a scheme
let normalizedBase = baseUrl.trim();
if (!/^https?:\/\//i.test(normalizedBase)) {
normalizedBase = 'https://' + normalizedBase;
}
const redirectUrl = normalizedBase + '?referrer=' + encodeURIComponent(currentUrl);
const url = new URL(redirectUrl);
window.location.href = url.toString();
} catch (err) {
console.error('Invalid redirect URL:', err);
}
}, 3000);
</script>
Auto-Browse for a Single Knoc
The auto-browse option available within the Knoc configuration, automatically forwards the user after successful login, to the Knoc should it be the only Knoc they have available to them.
This can streamline the users login experience, and depending on the protocol (eg: https or sftp, SAP, etc) their workstation can automatically launch the required software if this sits outside the web browser.
Also note that if this is the users only available Knoc, the card will not be visible prior to the auto-browse redirect.
