make an url password protected from direct accessing htaccess
<p>I am new to <code>.htaccess</code> . I have two files named <code>page1.php</code> and <code>page2.php</code>,while <code>page2.php</code> is in another folder and <code>page1.php</code> has a link to it.I want to make <code>page2.php</code> password protected when someone wants to open <code>page2.php</code> directly hitting the URL.<br>
But it should be open when someone wants to go to that page from <code>page1.php</code> page.</p>

<p>Can anyone help me out to get this done?</p>

<p>Note:I have already added the following thing to my .htaccess . But here this page is password protected in both ways no matter someone open it directly or go to that page from <code>page1.php</code> . I want to make it password protected only when directly want to go to that page.</p>

<pre><code>AuthUserFile C:/wamp/www/htaccess_pwd/main/.htpasswd.txt 
AuthType Basic
AuthName "You need to be authorized!!"
Require valid-user

&lt;Files "page2.php"&gt;
Require valid-user
&lt;/Files&gt;
</code></pre>