title: PHP - Deny access to a page when entering not from a link
body: <p>Is there a way to deny access to a certain page but only when accessing it via url? I have a link which loads a page into <code>div</code> element but don't want anyone accessing that page via url (e.g. <code>&lt;address&gt;/pages/contact.php</code>). I want it to redirect back to <code>index.php</code>.</p>
  
  <p><strong>jQuery load code:</strong></p>
  
  <pre><code>$(function() {
      $('.content').load('pages/home.php');
  
      var selector = '.side .nav li a';
      $(selector).click(function() {
          $(selector).removeClass('active');
          $(this).addClass('active');
  
          var target = 'pages/' + $(this).attr('class').split(' ')[0] + '.php';
          $('.content').load(target);
      }); 
  });
  </code></pre>
  
  <p><strong>My <code>php</code> code that doesn't work (redirects <code>content</code> to <code>index.php</code> as well):</strong></p>
  
  <pre><code>&lt;?php 
      header('Location: ../index.php');
  ?&gt;
  </code></pre>