Website Source code disable

Continuing the discussion from How to hide source code from public view:

Is it possible to hide website source code via .htaccess code?
Now a day there many websites are available who’s help to view source code of anywebsite.

Yes, There is one way to restrict source code via disable right clixk of mouse. But what happens when usee disable JavaScript.

What happen when user directly view source code by url from any third party website?

If someone looks at view-source, they see only the HTML, CSS and JavaScript. They will not see the PHP code (unless it’s below root and the PHP engine is down in which case they’ll see the file as text.

So make sure you put any files with sensitive information above the root. If your files are on a shared server this may not be 100% safe but should be good enough depending on what the information is.

2 Likes

As mentioned by @Mittineague and various users on the other topic that was linked, there is no definite way to “hide” or “disable” the viewing of a source code. If you really want to “hide” the source code from someone. The simplest way is to not release it at all. That is the only “possible” way to “hide” a source code. Other than that, if it’s a server-side language, no one can see those actual codes unless something is being outputted to the screen.

HTML, CSS, Javascript, and your assets are all client side. This means that everything the user sees, they can manipulate it or view it as they see fit. The only thing the user cannot see nor touch is the server-side stuff. This could be in PHP, Python, Ruby, ASP.NET, or any various languages for the web.

Again, don’t mistaken that if you nest your HTML codes inside something like PHP, that “no one” can see it. That is a misconception. Anything that is outputted to the screen, anyone can simply view the source code for it. Remember, HTML is the foundation to a website. It is the back-bone of the website. It is also an outputted element. That’s why it’s called Hyper Text Markup Language. Same concept goes for CSS and Javascript.

4 Likes

I would have to ask why you want to do that: what is the issue you are trying to address?

As others have said, it’s not possible to hide the source, but if we understand your problem we might be ab;e to offer other suggestions.

There was a similar question asked recently which might be of interest:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.