title: hiding files with php
body: <p>I can't wrap my head around this, and it is SO frustrating. I have no idea how I'd be solving my problem.</p>
  
  <p>I use sockets to connect with my NodeJS server, and I use PHP for routing people to the correct pages. When I route someone to the admin page I check if he is allowed to continue, if so I'll redirect him, if not I won't. Now here's the issue, people can just go to mywebsite.com/browser/admin.html and read everything that's in the admin panel (just the layout and stuff). I don't want people to be able and visit my admin panel to see what admins can do and can't do.</p>
  
  <p>Can I do this in any way? E.g. only show the admin panel if they have a certain rank; if they don't have that rank they <strong>WILL NEVER</strong> be able to visit the admin panel. I'd like to hide the html files and other files somehow.</p>
  
  <p><strong>Routing - .htaccess</strong></p>
  
  <pre><code>RewriteEngine on
  </code></pre>
  
  <p>RewriteRule ^/browser/admin.html$ index.php?page=admin [L,NC,QSA]</p>
  
  <pre><code>RewriteCond %{DOCUMENT_ROOT} !-f
  RewriteRule ^(\w+)$ index.php?page=$1 [L,NC,QSA]
  RewriteRule ^(\w+)+\/$ index.php?page=$1 [L,NC,QSA]
  </code></pre>
  
  <p><strong>Routing - index.php</strong></p>
  
  <pre><code>function route(){
      global $db;
      global $user;
  
      $page = $_GET['page'];
  
      if(!isset($page)) {
          header('Location: /home');
      }
  
      if($page === 'home'){
          loadWebpage('index.html', array());
      }else if($page === 'admin'){
          if($user['rank'] !== 'admin'){ /* This works but people can still access the files since they are loaded on the frontend with myexample.com/browser/admin.html */
              echo 'Access denied.';
              return;
          }
  
          loadWebpage('admin.html', array())
      }
  }
  
  route();
  </code></pre>
  
  <p>I'm sorry if I haven't explained it well, but I hope you understand what I mean; I find it difficult to explain the things I want. I appreciate the help.</p>