The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Hide my files from user

Discussion in 'General Discussion' started by yogev, Jul 25, 2015.

  1. yogev

    yogev Member

    Joined:
    Jul 25, 2015
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    null
    cPanel Access Level:
    Website Owner
    Hi, I'm new to cpanel and i want to hide my files from user.

    For example, now if someone enter ib the URL "www.mydomain/folder/file.js"

    He can view my code. How can I disable this?

    I already have a redirect on the folder, and disabled index on the folder. Still same thing
     
  2. dalem

    dalem Well-Known Member
    PartnerNOC

    Joined:
    Oct 24, 2003
    Messages:
    2,577
    Likes Received:
    40
    Trophy Points:
    48
    Location:
    SLC
    cPanel Access Level:
    DataCenter Provider
    Javascript is a client-side programming language, therefore it works on the client's machine, so you can't actually hide anything from the client.
     
  3. yogev

    yogev Member

    Joined:
    Jul 25, 2015
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    null
    cPanel Access Level:
    Website Owner
    But i want to hide it with the server, in this moment everyone can just view my code abd copy it. There is no solution?
     
  4. cPTerrance

    cPTerrance *nix Technical Analyst II / Migrations Specialist
    Staff Member

    Joined:
    Jul 9, 2015
    Messages:
    72
    Likes Received:
    8
    Trophy Points:
    8
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Twitter:
    If you are serving the JS/JavaScript to a client, there is no way to "hide" it; it is a client side scripting language. If you don't need to serve it, you can move it outside of public_html
     
    yogev likes this.
  5. yogev

    yogev Member

    Joined:
    Jul 25, 2015
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    null
    cPanel Access Level:
    Website Owner
    I think that this is my answer.
    If i will move my folder i will need to re direct my files tovthe path?
    From <src = folder/file.js>
    To <src =.. /folder/file.js>

    I will check this out as soon as I get home and let you know if that did the job.

    Thank you for your answer!
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I'm happy to see the solution offered was helpful. Feel free to update this thread with the outcome when you have the time.

    Thank you.
     
    yogev likes this.
  7. yogev

    yogev Member

    Joined:
    Jul 25, 2015
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    null
    cPanel Access Level:
    Website Owner
    Unfortunately this is not what i expected, my js file should be out of reach for the user, but the html is using it.

    If I'm moving my file out of the public_html im getting a "forbidden" page when the index.html is trying to reach it's code.

    How can i hide it from the user?
    It is not making any sense that any user will be able to view my js code.
     
  8. cPTerrance

    cPTerrance *nix Technical Analyst II / Migrations Specialist
    Staff Member

    Joined:
    Jul 9, 2015
    Messages:
    72
    Likes Received:
    8
    Trophy Points:
    8
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Since it is javascript it is a browser-interpreted file which means that the user will have to be able to read it since the browser has to be able to read it. There is nothing you can do to prevent this from happening.
     
  9. yogev

    yogev Member

    Joined:
    Jul 25, 2015
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    null
    cPanel Access Level:
    Website Owner
    Yeh.. I just realized how low my coding was.
    I didn't implemented a server side.
    My solution is to install node.js on my server and use an api to access my db.

    Thank you all for your answers
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page