Claudiu Creanga
Claudiu Creanga

Reputation: 8366

how to hide my source code so to not be copied

I was recently informed by someone that my website was copied. When I looked at the linked that he gave me I so that the site was identic to mine except for the logo and text. Is there a way to hide my code? Or to make it impossible to right click on my page? I saw on some websites that if you go to http://example.com/images/ it will show access denied, not a list with all your images...How do they do it? Thank you!

Upvotes: 18

Views: 82488

Answers (8)

KroKite
KroKite

Reputation: 74

There is no full proof way.

But here is some strategy that can be employed to hide source code like using "window.history.pushState()"

Detail here - http://freelancer.usercv.com/blog/28/hide-website-source-code-in-view-source-using-stupid-one-line-chinese-hack-code

Upvotes: 0

Andrew
Andrew

Reputation: 2975

imho, it is impossible. Even if you block right click, F12, Ctrl+C/V, or others shortcut to copy, you can still counter with disable JavaScript and copy the the page source.

Upvotes: 0

chike
chike

Reputation: 9

just create an empty index.html page and upload to your images folder, that solves it, so whenever they use /images..

Upvotes: 0

NullPoiиteя
NullPoiиteя

Reputation: 57322

Don't do this! It makes no sense to do this, since the user can disable the script, and there are many tools like Firebug by which a user can see the code.

The best way to keep safe the store is installing a security camera while leaving the doors open.

You can simply disable the right click by following:

<body oncontextmenu="return false">
  ...
</body>

or

<script language="javascript">
  document.onmousedown = disableclick;
  status = "Right Click Disabled";
  Function disableclick(e)
  {
    if(event.button == 2)
    {
      alert(status);
      return false; 
    }
  }
</script> 

The code above is from this article

Upvotes: 12

Will Palmer
Will Palmer

Reputation: 5952

No, there is no way to hide one's code on the web. If you're sending information to the client-side, that information can be copied. That's not merely a fact of the web, that's a fact of information theory. The only option for cases like this is not prevention, but detection. Many services exist to help in these situations.

Depending on your web host, preventing the listing of files in an images/ directory, for example, may be done by adding an .htaccess file with appropriate restrictions, or disabling directory listings from within your host's panel. The key words you need are "disabling directory listings". Talk to your webhost's support for more details, this is a very common request, so they likely already know exactly how to help you.

Note that this will only prevent the listing of images in a convenient form. If they are referenced on other pages on your site, they can still be easily downloaded.

Upvotes: 8

Aron Jay
Aron Jay

Reputation: 155

In that case, probably they have an access to your ftp account. If I were you I will change my ftp credentials.

And also, there are tools that would really copy all of the websites content, including its source codes. One notable is IDM or Internet Download Manager http://www.internetdownloadmanager.com/ which has a Site Grabber feature.

Upvotes: 3

akton
akton

Reputation: 14386

Hiding the right click handler only stops honest people from getting the page source and not those using tools like wget or curl. You can obfuscate or minify your JavaScript (such as using Google Closure) but, if the browser needs to get access to the code or content, so can someone who is malicious.

Upvotes: 2

Grant Thomas
Grant Thomas

Reputation: 45083

You can do stuff which amounts to security through obscurity, but the only way to prevent your client-side web source from being copyable is to not push it down the wire, to not deliver it in the first place, shut down your website.

Upvotes: 14

Related Questions