subfolder protection by htaccess

Discussion in 'Apache' started by YacaZG, Jan 23, 2017.

  1. #1
    hello,

    I want to protect by htaccess/htapsswd one of subfolder on my website. is possible to do it from htaccess file in root directory?

    Thank you for answer
     
    YacaZG, Jan 23, 2017 IP
  2. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #2
    Hello,

    You can simply place an .htaccess with the authentication information within the sub-folder to protect it. Is there a specific reason you want to handle this outside of this folder?

    Regards,
    Chris
     
    RHS-Chris, Jan 24, 2017 IP
  3. YacaZG

    YacaZG Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    I can't place .htaccess in sub-folder, because in root directory is another .htaccess,
    .htaccess in sub-folder inherits from .htaccess in root directory, and protection is not working, sub-folder website is not available, because it's not opening window to write login and passowrd
     
    YacaZG, Jan 25, 2017 IP
  4. AlexMGM

    AlexMGM Greenhorn

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #4
    yes you can do it in parent .htaccess like this:

    
    <Directory /path/to/protected/>
    Require user myuser
    </Directory>
    
    Code (markup):
     
    AlexMGM, Jan 26, 2017 IP
  5. AlexMGM

    AlexMGM Greenhorn

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #5
    Also, if you want to nest .htaccess and it does not allow it, check if you have "AllowOverride All" in parent .htaccess
     
    AlexMGM, Jan 26, 2017 IP
  6. YacaZG

    YacaZG Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Is this correct?

    <Directory /wp-admin/>
    Require user yacazg
    </Directory>

    But where is path to .htpasswd file?
     
    YacaZG, Jan 26, 2017 IP
  7. YacaZG

    YacaZG Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #7
    <Directory /path/to/protected/>
    Require user myuser
    </Directory>

    is making 500 internal servers errors
     
    YacaZG, Jan 26, 2017 IP
  8. AlexMGM

    AlexMGM Greenhorn

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #8
    Please post here your parent .htaccess and nested one too.
     
    AlexMGM, Jan 27, 2017 IP
  9. MagdaS

    MagdaS Active Member

    Messages:
    37
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    88
    #9
    Same problem here.

    Solved it by replacing Apache2 with nginx.
     
    MagdaS, Feb 3, 2017 IP