So I've attempted to add this javascript to the navigation page to check for the attempted href but the page isn't reloading even though the check is true (I've tested it with window.open instead and it did open google!) Is there anything wrong in this code?
var current = window.location.href;
var s = current.split("https://www.mainsite.org/");
if (s[1].includes("microsite")) {window.location.replace("https://www.google.ca"); }
Edit: I figured out another way to use macros in URL redirection instead of javascript.
{% Contains(CurrentDocument.NodeAliasPath, "/microsite/") ? "/microsite/pagenotfound" : "/SpecialPages/PageNotFound" |(identity)GlobalAdministrator%}