php - make an url password protected from direct accessing htaccess -
i new .htaccess . have 2 files named page1.php , page2.php,while page2.php in folder , page1.php has link it.i want make page2.php password protected when wants open page2.php directly hitting url.
should open when wants go page page1.php page.
can me out done?
note:i have added following thing .htaccess . here page password protected in both ways no matter open directly or go page page1.php . want make password protected when directly want go page.
authuserfile c:/wamp/www/htaccess_pwd/main/.htpasswd.txt authtype basic authname "you need authorized!!" require valid-user <files "page2.php"> require valid-user </files>
solution1:
if dealing .php files, think easiest code in php. page1.php:
<?php session_start(); $_session["log"]="ok"; ?> page2.php:
<?php session_start(); if(isset($_session["log"])){ ?> //your site <?php }else{ ?> not allowed enter!!! <?php } ?> solution2:
include password link on page1.php (will cause errors on browsers)
<a href="user:password@http://yourserver/page2.php">log in</a>
Comments
Post a Comment