I want to put in my HTML/PHP a script for redirection if the website name does not match my word. I tried to use this code, but it doesn't work.
WITH REGEX
if (window.location.hostname !== 'myword.org'){
window.top.location.href = 'http://redirecttomysite.org';
}
var website = window.location.hostname;
var internalLinkRegex = new RegExp('^((((http:\\/\\/|https:\\/\\/)(www\\.)?)?'
+ website
+ ')|(localhost:\\d{4})|(\\/.*))(\\/.*)?$', '');
WITHOUT REGEX
if (website !== 'myword.org'){
window.top.location.href = 'http://redirecttomysite.org/forum';
}