Redirect Website if its not specified domain in script - Protection using Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hardik4mail
    New Member
    • Apr 2013
    • 2

    #1

    Redirect Website if its not specified domain in script - Protection using Javascript

    Brief Idea: I am building script for protecting my webdesign work by locking them on Single domain. If website is uploaded on different domain, It will redirect to my website. Means it won't allow to load actual website from different domain except I specify them.

    My Working Script:

    -- DECODED SCRIPT --

    Code:
    []['constructor']['constructor'](self['unescape']('if(~location.protocol.indexOf('http:')&&~location.host.indexOf('isupportu.in')){}else(location.href='http://iamwebdeveloper.in')'))()
    Here on above code, I am allowing my work to load on "www.abc.co m" with http protocol only. However it won't work if we load website without www i.e. "abc.com".

    www.abc.com --> Website load

    abc.com --> www.iamwebdeveloper.in

    xyz.com --> www.iamwebdeveloper.in

    www.xyz.com --> www.iamwebdeveloper.in
    I decided to use .htaccess / web.config file to force redirect domain without www. request to www.abc.com [which is working very well]

    But now I want to upgrade this script and I need your help:

    Don't want dependency on .htaccess / web.config file for redirecting non www. request.
    www. and non www request should accept, but no subdomain allow. For e.g. subdomain.abc.c om is not allowed.
    I want to add multiple domains in script for big clients who has multiple domain for their single website as Addon domain. I want to add more domain in above script.
    I hope this will be more interesting task for you too, same as mine.


    Can someone help me to validate this script for my above logic ?
    Code:
    []['constructor']['constructor'](self['unescape']('if(~location.protocol.indexOf('http:')&&~location.host.indexOf('isupportu.in')||~location.host.indexOf('site2.in')||~location.host.indexOf('site3.in')){}else(location.href='http://iamwebdeveloper.in')'))()
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what if I remove that redirecting line? it’s only JavaScript, after all.

    Comment

    • hardik4mail
      New Member
      • Apr 2013
      • 2

      #3
      I am agree with you but I am injecting this code in multiple JavaScript include in jQuery script and encrypting all js. Nothing is foolproof protection but at least we can slow them.

      Comment

      Working...