2

Before this question I asked about disabling file and folder listing and I found an answer that this can be done with a file called .htaccess. For disabling folder listing I write Options -Indexes in the .htaccess file and place it in the parent folder, on the other hand for disabling display of files content in the browser I write Deny from all.

The above part functions good, but when a putted the .htaccess file for disabling display of files content in the css or js folder, it disables display of files and also blocks the functionality of them (.css and .js).

Is there an answer that disables the display of files in the browser but allows the functionality of them?

Thank you

4
  • I suspect that you don't want users to be able to go to www.domain.com/css/stylesheet.css ? Commented Jan 5, 2016 at 15:57
  • Yes, that is my question Commented Jan 5, 2016 at 16:08
  • As stated in the answers, that is impossible. Your browser needs to see the files, needs to be able to access them. If you can't link to them you can't use them. Commented Jan 5, 2016 at 16:10
  • This doesn't make sense. Every site from the largest sites in the world can't hide CSS. There is no point. And trust me there is nothing you can do that someone else can't. Also you don't even need to view the CSS or JS files directly to see the code. The Chrome DEV tools and other browsers allow you to see the styles that are applied. It's a mute point period. Commented Jan 5, 2016 at 17:32

3 Answers 3

4

No.

You can turn off directory listings because nothing needs to see them.

You can't turn off display of CSS or JS because the browser has to be able to see them in order to use them for what they are designed for. Anything the browser can see, the user can see too.

Sign up to request clarification or add additional context in comments.

4 Comments

OP doesn't want to turn off CSS or JS Is there an answer that disables the display of files in the browser but allows the functionality of them
@DarrenSweeney — Exactly. They want to disable the ability of the user to View Source the CSS or JS while still allowing the browser to execute the JS and apply the CSS to the page. (Which is, as I said in this answer, impossible).
From this, I should give a hard .css or .js name that wouldn't be accessed.
@user3625176 — And then you have to tell the browser what that name is so that it can request it so that it can render the page correctly. And since you gave the name to the browser, you also gave it to the user.
0

It is possible to disable the listing of files, but you cannot protect them since they are required for your website to load the style, or functions...

Comments

0

Try looking up minifying and obfuscating.

Minifying makes your files harder to read. Obfuscating can completely encode your files (only tried with JS so far myself). But be sure to keep a backup of your files, because once encrypted, you can't go back.

Here is a link for obfuscating JS files:

Obfuscate JS

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.