• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

restricting access to pages

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On apache how can I restrict access to pages ..
someone mentioned using .htaccess ?
how do I do restrict access say by username or say the type fof files ...
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bina,
Access control for a given directory is controlled by a specific file in the directory with the name .htaccess
So let's suppose you want to restrict files of user bina in a directory called turkey to username pumpkin and password pie. Here's what to do:
Create a file called .htaccess in binas directory turkey that looks like this:
AuthUserFile /home/bina/.htpasswd
AuthGroupFile /dev/null
AuthName Johns page
AuthType Basic
require valid-user
AuthUserFile must be the full pathname of the password file. This path can differ per ISP, so you'll have to contact your technical support contact for it, if the above stated example doesn't work.
Also note that in this case there is no group file, so we specify /dev/null (the standard Unix way to say "this file doesn't exist").
Create the password file /home/bina/.htpasswd
You can do this using a tool on the WWW. All you need to do is fill in a name, the password and then re-type the password. The password calculator calculates a diffrent encrypted version every time you run it, this is not something to be alarmed about.
Using cut & paste (or by simply typing the password over) you save all the lines in the password file, and upload that file to the server. A normal password file that allows acces to pumpkin, radish and bina would look something like this :
It's crucial that you press enter after each line (the last line should be an empty one, not a line with a password entry in it) and that you upload the file as 'text' or 'ascii'. Also, keep in mind that these lines are case-sensitive; you should enter a capital as a capital and a lower-case character as a lower-case character.
That's all. Now try to access a file in directory turkey -- your browser should demand a username and password, and not give you access to the file if you don't enter pumpkin and pie. If you are using a browser that doesn't handle authentication, you will not be able to access the document at all.
I hope you will get your solution.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic