How to Password Protect a Directory With .htaccess

Поділитися
Вставка
  • Опубліковано 13 гру 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

  • @RankYa
    @RankYa  10 років тому +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

  • @MystalurDimensh
    @MystalurDimensh 4 роки тому +2

    Finally a video that explains it properly! Thank you!

  • @xdebono7613
    @xdebono7613 7 років тому +2

    Well done.....very easy to follow

  • @nomdplume6166
    @nomdplume6166 7 років тому +3

    Really useful video! Thanks a bunch for sharing!

  • @WishowMetal
    @WishowMetal 7 років тому

    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 7 років тому

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

    • @RankYa
      @RankYa  7 років тому

      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 7 років тому

      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  7 років тому +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

  • @dand5102
    @dand5102 7 років тому +2

    Very useful. Thank You!

  • @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

  • @georgeriley4839
    @georgeriley4839 3 роки тому

    That worked brilliantly thank you.

  • @carloautor
    @carloautor 5 років тому

    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  5 років тому

      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 ua-cam.com/video/JKHuhvBBhBQ/v-deo.html

  • @petermax4593
    @petermax4593 7 років тому

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

  • @2667cooper
    @2667cooper 10 років тому +1

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

    • @TVPMLP
      @TVPMLP 7 років тому

      save as all file type

  • @venustheplanet8208
    @venustheplanet8208 4 роки тому

    Tarek and Haya thank you.
    Vincent too.

  • @puluqemil
    @puluqemil 9 років тому +2

    very useful, thank you.

  • @RetoxMedia
    @RetoxMedia 6 років тому +2

    Brilliant tutorial

  • @jsc8409
    @jsc8409 5 років тому

    does it still open in explorer ?

  • @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 UA-cam channel so that other coders can also benefit

  • @lasansudeera6016
    @lasansudeera6016 6 років тому +1

    Thank you very much!

  • @calin8817
    @calin8817 7 років тому +2

    You save my day.
    Tks

  • @karunasagar3465
    @karunasagar3465 9 років тому +1

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

  • @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)

  • @alexenache2910
    @alexenache2910 7 років тому +1

    a very "OK!" video :) thank you

  • @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

  • @muruligowda2985
    @muruligowda2985 8 років тому

    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  8 років тому

      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:

  • @malachi5813
    @malachi5813 7 років тому +2

    well done sir!

  • @greengrass1970
    @greengrass1970 9 років тому +1

    Thanks - you saved my day :-)

  • @VladimirOnOccasion
    @VladimirOnOccasion 4 роки тому +1

    nice video

  • @rajeshmoravaneni6630
    @rajeshmoravaneni6630 3 роки тому

    Thank You.

  • @cherniyosser4797
    @cherniyosser4797 7 років тому +1

    thank u so much :)

  • @nazrulhanif6372
    @nazrulhanif6372 7 років тому

    thanks a lot

  • @876Abb
    @876Abb 6 років тому

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

    • @RankYa
      @RankYa  6 років тому

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

    • @RankYa
      @RankYa  6 років тому

      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

  • @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)

  • @VarnexArts
    @VarnexArts 7 років тому +1

    100th like. :D

  • @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