anups Posted June 13, 2011 Share Posted June 13, 2011 I have 3 pages on my website 1. http://xyz.com/user.php 2. http://xyz.com/admin.php 3. http://xyz.com/superadmin.php Now I want to show http authentication using ".htaccess" && ".htpasswd" for "admin.php" & "superadmin.php". I cannot use php code header('WWW-Authenticate: Basic realm="My Realm"'); As per my knowledge http authentication using ".htaccess" files works only on directories not on pages. Please help me in achieving this. Quote Link to comment https://forums.phpfreaks.com/topic/239216-htaacess-authentication/ Share on other sites More sharing options...
gizmola Posted June 13, 2011 Share Posted June 13, 2011 Wrong. As you stated correctly, the built in authentication works on directories. Thus you DO want to use php code to restrict access to files -- there is no other option. The ways you can do this with php are described here: http://php.net/manual/en/features.http-auth.php What's nice about this is that you can use your own user table or file rather than using something like the htpasswd program that requires shell access or some wrapper script and is typically difficult and confusing for people who aren't sysadmins. Quote Link to comment https://forums.phpfreaks.com/topic/239216-htaacess-authentication/#findComment-1229288 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.