If the site is located on the same name.ru domain, then redirection is not needed.
If the site is stolen and placed on the left site, it should be redirected to name.ru
How can this be implemented?
If the site is located on the same name.ru domain, then redirection is not needed.
If the site is stolen and placed on the left site, it should be redirected to name.ru
How can this be implemented?
Who really needs to copy your site or content, that will copy it, and any protection is unlikely to stop it. If your site is being copied, it means you have really created something good.
If you still want to somehow protect against copying technically using javascript ...
If you need an exact match on the domain, then this code:
if (window.location.host !== 'name.ru') { window.location = 'http://name.ru' } If you want to allow your code to be placed on subdomains, then this one:
if (/\.name\.ru$|^(w{3}\.)?name\.ru$/.test(window.location.host)) { window.location = 'http://name.ru' } So for strict comparison:
// Разворот строки function rv(s){ return s.split("").reverse().join(""); } // Экранирование домена перед подстановкой в регулярное выражение function e(s) { return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); } // Редирект function r(d) { var t = 'h' + (new Array(3).join('t')) + 'p:' + (new Array(3).join('/')) + d; window[rv('noitacol')][rv('ferh')] = t; } // Проверка текущего домена function c(d) { var p = '/^' + e(d) + '$/'; return (new RegExp(p)).test(window.location.host) ? true : r(d); } var k = 'name.ru'; c(k); That's the way to allow placement on subdomains:
// Разворот строки function rv(s){ return s.split("").reverse().join(""); } // Экранирование домена перед подстановкой в регулярное выражение function e(s) { return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); } // Редирект function r(d) { var t = 'h' + (new Array(3).join('t')) + 'p:' + (new Array(3).join('/')) + d; window[rv('noitacol')][rv('ferh')] = t; } // Проверка текущего домена function c(d) { var p = '/\.' + e(d) + '$|^(\u0077{3}\.)?' + e(d) + '$/'; return (new RegExp(p)).test(window.location.host) ? true : r(d); } var k = 'name.ru'; c(k); The domain itself is not encrypted, but you can make it difficult to search for it by breaking the string into several parts or initially stitching a value encoded by some algorithm, to which the decryption is immediately applied before being written into the c() function.
Used information from here:
How do you reverse the string in javascript?
Javascript for PHP functions: str_repeat
Is there a RegExp.escape function in Javascript?
Source: https://ru.stackoverflow.com/questions/527735/
All Articles
стырили сайт, uh, what are you sorry? - Vasily Barbashevdocument.location.hrefsame. Only it is unlikely that those who have the sense to "steal" your site will not be able to remove any of your redirects. - Dmitriy Simushev