How to Password Protect a Directory With .htaccess

Поделиться
HTML-код
  • Опубликовано: 26 авг 2024
  • How to password protect a directory with .htaccess outlines step by step methods for password protecting a web folder.
    At times you may want to password protect certain parts of your website, then the easiest method (although never fully secure) is to use .htaccess file for securing your folders/directories. Or perhaps you want to just learn how to password protect using apache web server directives to gain more web security knowledge. To learn more about Authentication using apache server directives visit:
    httpd.apache.o...
  • ХоббиХобби

Комментарии • 52

  • @MystalurDimensh
    @MystalurDimensh 4 года назад +2

    Finally a video that explains it properly! Thank you!

  • @RankYa
    @RankYa  9 лет назад +8

    Simply open that .txt file, and then "File >Save As" and then find "Save As Type" option and select "All files (*.*)" because then you will be able to save it as .xyz

  • @xdebono7613
    @xdebono7613 7 лет назад +2

    Well done.....very easy to follow

  • @sanchitaggarwal6522
    @sanchitaggarwal6522 7 лет назад +1

    This video is soo helpfull. I like the way explain . you are soo good . I really appriciate.
    Thank. you for sharing

  • @nomdplume6166
    @nomdplume6166 7 лет назад +3

    Really useful video! Thanks a bunch for sharing!

  • @dand5102
    @dand5102 7 лет назад +2

    Very useful. Thank You!

  • @georgeriley4839
    @georgeriley4839 3 года назад

    That worked brilliantly thank you.

  • @karunasagar3465
    @karunasagar3465 9 лет назад +1

    That very good tutorial i am very thank full to you its help me lot

  • @RetoxMedia
    @RetoxMedia 6 лет назад +2

    Brilliant tutorial

  • @lasansudeera6016
    @lasansudeera6016 6 лет назад +1

    Thank you very much!

  • @calin8817
    @calin8817 7 лет назад +2

    You save my day.
    Tks

  • @puluqemil
    @puluqemil 9 лет назад +2

    very useful, thank you.

  • @venustheplanet8208
    @venustheplanet8208 3 года назад

    Tarek and Haya thank you.
    Vincent too.

  • @malachi5813
    @malachi5813 7 лет назад +2

    well done sir!

  • @alexenache2910
    @alexenache2910 7 лет назад +1

    a very "OK!" video :) thank you

  • @petermax4593
    @petermax4593 6 лет назад

    the authentication is not req. again in same browser chrome this is not req. for pass when i refresh the page

  • @rajeshmoravaneni6630
    @rajeshmoravaneni6630 3 года назад

    Thank You.

  • @greengrass1970
    @greengrass1970 8 лет назад +1

    Thanks - you saved my day :-)

  • @VladimirOnOccasion
    @VladimirOnOccasion 4 года назад +1

    nice video

  • @jsc8409
    @jsc8409 5 лет назад

    does it still open in explorer ?

  • @gagatvshare
    @gagatvshare 6 лет назад

    Hi, i done all the process properly. It works upto 10 days only. Know, it is not working. When i enter the user id and password. It shows the same login request only. how to solve it.

    • @RankYa
      @RankYa  6 лет назад

      Sorry Ganesh but I don't know why this would be, as in work for 10 days and now doesn't work. I would really appreciate you comment back when you work out the cause and solution to this

  • @cherniyosser4797
    @cherniyosser4797 6 лет назад +1

    thank u so much :)

  • @2667cooper
    @2667cooper 9 лет назад +1

    my ".htmyxyz" file is automatically saving as a .txt file... how do I fix?

    • @TVPMLP
      @TVPMLP 6 лет назад

      save as all file type

  • @carloautor
    @carloautor 4 года назад

    Hi. Just wanna ask, is there a way that I can terminate the session once they close the tab or the webpage? Thank you

    • @RankYa
      @RankYa  4 года назад

      Hello Carlo, with PHP much is possible. Could be complex to achieve dependent on your skill level. But I think these will help stackoverflow.com/questions/24402047/php-session-destroy-after-closing-browser ruclips.net/video/JKHuhvBBhBQ/видео.html

  • @jasmeetsingh9804
    @jasmeetsingh9804 4 года назад

    how can we restrict particular URL in the website rather than folder.

    • @RankYa
      @RankYa  4 года назад

      Hello Jasmeet, check this URL out which may help stackoverflow.com/questions/14603568/password-protect-a-specific-url if you find a solution please come back and comment on #RankYa RUclips channel so that other coders can also benefit

  • @muruligowda2985
    @muruligowda2985 7 лет назад

    Sir I Want Same Authentication But Using Login.php and style.css Page. And Giving Right username and password it's true then it redirect the welcome.php page...Please tel me how to do.

    • @RankYa
      @RankYa  7 лет назад

      I would presume that your private folder would have index.php (thus your login.php content placed in it) which you can style.css it as well. as for redirection I am not sure but this may help stackoverflow.com/questions/20506931/apache-htaccess-redirect-based-on-logged-in-user
      For php redirection this can work:

  • @WishowMetal
    @WishowMetal 6 лет назад

    Please, help!
    It is not working for me.
    I have another necessary rules in the .htaccess file that is located into the folder I want to protect (for https redirection). Since I added the validation rules, the folder can't be reached, I just see a NOT FOUND ERROR PAGE of my main domain, which is a WordPress site.
    What am I doing wrong?

    • @WishowMetal
      @WishowMetal 6 лет назад

      I've even done the process via cPanel assistant, but no results.

    • @RankYa
      @RankYa  6 лет назад

      I am not sure, because https redirection shouldn't make any difference from my understanding (or perhaps it may I am not sure for your setup). Anyhow, I think you got it fixed now? If so, please do share *how* you managed to do that. Thanks for sharing your input and yes if the #WordPress is installed in a sub-directory, your blog post information has that / forward slash (as you know represents another level of directory)

    • @WishowMetal
      @WishowMetal 6 лет назад

      Yeah, I fixed it by following these steps: www.nivindel.com/htaccess-password-protection-subdirectory-wont-work-wordpress/. It's due to the Permalinks structure of WP. Then, it's necessary to modify the htaccess file generated by WP too. Thanks for your reply!

    • @RankYa
      @RankYa  6 лет назад +1

      Great to hear, as for others reading this, make sure you backup .htacces file before experimenting, to learn more about .htaccess directives visit: codex.wordpress.org/htaccess

  • @nazrulhanif6372
    @nazrulhanif6372 7 лет назад

    thanks a lot

  • @VarnexArts
    @VarnexArts 7 лет назад +1

    100th like. :D

  • @dibraniuk
    @dibraniuk 7 лет назад

    are you using file manager? where to download that from ? thx

    • @RankYa
      @RankYa  7 лет назад

      I use FileZilla FTP program, however, you can easily login to your web hosting > File Manager (and do everything there)

  • @4TruthBeTrue
    @4TruthBeTrue 6 лет назад

    would this work on an Amazon S3 ?

    • @RankYa
      @RankYa  6 лет назад

      That's a good question, more than unlikely, however, there must be a way to protect folders/files regardless of server setup (let us know the outcome please)

  • @876Abb
    @876Abb 5 лет назад

    Video tutorial is not for everyone...he made it so hard to follow as he beats about the bush

    • @RankYa
      @RankYa  5 лет назад

      You may find this of help as well www.htaccesstools.com/articles/password-protection/

    • @RankYa
      @RankYa  5 лет назад

      Or this for those who find the video tutorial for password protection using .htaccess overwhelming stackoverflow.com/questions/5229656/password-protecting-a-directory-and-all-of-its-subfolders-using-htaccess

  • @kaceyhowell6570
    @kaceyhowell6570 6 лет назад +1

    Not a good video for people hosting their own apache server on a Windows machine.

    • @RankYa
      @RankYa  6 лет назад

      Thanks for the comment Kacey, can you by any chance briefly outline the steps for local apache server? That would be great

    • @kaceyhowell6570
      @kaceyhowell6570 6 лет назад +1

      I was going to do that earlier todayMost of it is the same, except for the file structure
      1: Add:
      *
      AllowOverride AuthConfig
      *
      To your httpd.conf file and restart your apache service
      2: Create an *.htpasswd* file and put it in the directory you want to protect and add this to the file:
      *AuthType Basic
      AuthName "Please Enter the Password to access this page"
      AuthUserFile C:Path/To/Your/Directory/You/Want/To/Protect/.htpasswd
      require valid-user*
      3. Use an *htpasswd* generator to create a username:password combo, I used this one www.web2generators.com/apache-tools/htpasswd-generator
      4. paste that into a .htaccess file that you create and put that in to the protected directory as well.
      That is about it. Like I said. Mostly the same, just the filesystem differences makes it hard to follow the video for a Windows user hosting an apache server. That is all I did to make mine work. hope that helps someone.

    • @RankYa
      @RankYa  6 лет назад

      Thanks Kasey for this great information, you are the best