I have the following code, which works great except it also catches subdomains on the same domain. For example if on example.ca and I want to go to sub.example.ca it will not let me. I understand that the site is technically different but I do not need the warning for these pages.
Also on the site sub.example.ca (since it uses most of the same files) triggers for every internal link since the internal links are now sub.example.ca which is really annoying.
I could use the bypass variable but do not want to go through adding it to every menu and page I create. Laziness at it's best. haha.
$(document).ready(function() {
$("a").click(function() {
var href = this.href;
var ourDomainRegex = /^https?:\/\/(www[.])?example[.]ca/;
// those seeking flexibility, consider this:
// new RegExp('^https?:\\/\\/(www[.])?' + ourDomain)
if (href.indexOf("http") === 0 && ! ourDomainRegex.test(href) )
{
if($(this).attr('rel')!='pass') {
this.href = "/leave.php?p=" + href;
}
}
});
});
How would I go about getting it to work for subdomains. Thanks!