Jump to content

.htaacess authentication


anups

Recommended Posts

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.

 

Link to comment
Share on other sites

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. 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.