Hi!
How can I prevent from downloading my external Javascript and external CSS files from web server. As anyone who can view my web page code, can easily download my javascript and CSS files?
Is there any method or settings through htaccess file to prevent from downloading/copying files?
2- How can I prevent from viewing directory listing on my web server?
No, it’s not possible. If the browser can get at it, so can any user. The only thing you can do with javascript is obfuscate it with something like packer. With CSS all you can really do is remove whitespace in the declaration block.
Still, I don’t think this is very nice and goes against the spirit of the internet. Sure, people do steal, but it’s the same with anything. Most people like looking at CSS and JS to learn how something has been done.
Nobody should be able to see the directory if an index.html page is present because it will be loaded automatically when the directory is selected. Just use index.html pages without any content.
Why would you want to block them? r937 had the best answer to that question. Removing the ability to view source files would be taking away from the spirit of the Internet. While it’s entirely possible that someone is going to steal your design and scripts, I wouldn’t spend any time and effort trying to prevent. Rather, try and create something custom and unique that is copy writable, but even fighting copywrite violations can be a waste of time.
For the browser to use them they have to be downloaded to each visitor’s computer first so if you don’t want them to be downloaded there is no point in creating them in the first place since if they are not downloadable then the web page can’t use them.
Having a home page in the folder makes the -Indexes redundant. Easy enough to view the source of any HTML to see what JavaScript files it uses and call them directly. The -Indexes doesn’t block that.
The only real way of protecting your JScript is to run it under ASP.NET server side to generate the HTML there rather than updating it in the browser.
You know how easy it is to circumvent that… hey… 2 options. Craft a HTTP request (XmlHttp could even do that in JavaScript…) or take a look in the browser cache…
That is as many mouse clicks as it would have taken me to access the CSS or JavaScript from any web page (the first mouse click displays the HTML source with all of the external files displayed as links).
Per above, the best you can do is obfuscation if this is something running on the client. However, most of us here have benefited from others code, so…
Why not take the opposite approach? Comment your code, or point a reader to a pretty-print commented version. Maybe even set up a “how we did this cool effect” page. Encourage people to use your code.
Maybe you have actually come up with something new…a fix for an obscure bug, or some new visual effect. If so, spread the word. It’s likely the amount of goodwill towards your company will increase with this approach. Imagine people pointing others to your site to see the “Dr Dumb99 Fix” (fill your name or company name here).
You know how easy it is to circumvent that… hey… 2 options. Craft a HTTP request (XmlHttp could even do that in JavaScript…) or take a look in the browser cache…
dull dull dull.
I am giving the parent post the benefit of the doubt and assuming that the block directory listing question was separate from his copying/downloading question. It is quite a legitimate question, although it has nothing to do with source protection.