You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Htaccess.md 3.1 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. **.htaccess**
  2. Redbrick\'s Webserver, apache, allows users to password protected
  3. certain sections of their websites via a method known as \"htaccess\".
  4. This is done by creating a password file for authorized users and a
  5. .htaccess file in the directory which you would like to protect.
  6. ## Setting a password
  7. The password file comes first. To create a htaccess password file and
  8. assign an authorized user to it type:
  9. `htpasswd -c ~/passwd username`
  10. You can give the password file any name you like, just substitute the
  11. name you choose for passwd above. In this tutorial, references to passwd
  12. mean your password file. The value of username is the name of the user
  13. that you wish to grant access to. After running this command, you will
  14. be prompted to enter a password. This is the password that will be used
  15. by that user to gain access.
  16. To allow the server access to query this file you will need to change
  17. its file permissions. Type the following into your terminal:
  18. `chmod 755 ~/passwd`
  19. ## Directory Creation
  20. Next, you create a directory that will be protected by the password file
  21. you just made. For the tutorial, we will call this directory \"secret\",
  22. but you can call it whatever you want.
  23. Type the following into your terminal:
  24. `mkdir ~/public_html/secret`
  25. Once again the correct permission must be set. Simply type the following
  26. into your terminal:
  27. `chmod 711 ~/public_html/secret`
  28. Now you\'re almost done.
  29. ## .htaccess file
  30. With the password file and protected directory in place all that remains
  31. is the .htaccess file to tie it all together. The .htaccess file is what
  32. will tell the Webserver that the directory is password protected and
  33. requires authorisation.
  34. Change to your protected directory by typing:
  35. `cd ~/public_html/secret`
  36. Now type nano .htaccess to open the file in a text editor
  37. Copy and paste the contents of the sample htaccess file into the editor,
  38. making the necessary modification to the AuthUserFile line, e.g.
  39. `AuthType Basic`\
  40. `AuthName "User Login"`\
  41. `AuthUserFile /home/member/g/gizmo/passwd`\
  42. `require valid-user`
  43. **Note:** keep the name of the file .htaccess - this is an actual file
  44. extension recognised by Apache and it must be used.
  45. Lastly we need to set the permission on the file by typing:
  46. `chmod 644 .htaccess`
  47. ## htaccess & pubcookie
  48. You can use your htaccess file with the RedBrick pubcookie system. With
  49. this you can restrict access to redbrick members. See [PubCookie on
  50. Redbrick](/PubCookie_on_Redbrick "wikilink") for more.
  51. ## Testing
  52. To test if the directory is protected correctly, type its url into a
  53. browser, eg:
  54. `www.redbrick.dcu.ie/~username/secret`
  55. If all works correctly you should now be prompted for a username and
  56. password to gain access. If you\'d like to give access to another user,
  57. this is easily done using a similar command syntax to before:
  58. `htpasswd ~/passwd username`
  59. You\'ll be prompted to enter the new password twice as you were before.
  60. Once entered, the new user is active immediately and can gain access to
  61. the protected directory.
  62. As always, you can contact [Helpdesk](/Helpdesk "wikilink") if you have
  63. any problems.
  64. [Category:Helpdesk](/Category:Helpdesk "wikilink")