1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

question regarding .htaccess change / authentication

Discussion in 'Apache' started by phpUser1023, Feb 27, 2020.

  1. #1
    hello all,

    I'm a little new to this, but it's not too hard. I'm reading this:
    SEMrush
    https://cwiki.apache.org/confluence/display/HTTPD/PasswordBasicAuth

    the question I have, since it is not completely clear about what it's telling me to do is, can anyone here point me to some web resources where I can find an example of someone that has already done this? by "this" I mean set up authentication for users and passwords in a domain's .htaccess file and assigned different users' permissions to different directories on the server?

    thanks!

    Adam
     
    phpUser1023, Feb 27, 2020 IP
    SEMrush
  2. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    228
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #2
    It is well explained in the Apache documentation you sent.

    First you have to create a password file using the `htpasswd` utility:
    htpasswd -c /etc/.htpasswd user
    Code (markup):
    where `/etc/.htpasswd` can be any path on your server, and `user` will be the username used to access the protected directory.

    This will prompt you to enter a new password for `user` twice:
    
    New password:
    Re-type new password:
    Adding password for user
    
    Code (markup):
    Go to the directory that you want to be password protected and create a `.htaccess` file with the following content:
    
    AuthType Basic
    AuthName
    AuthUserFile /etc/.htpasswd
    Require user
    
    Code (markup):
    Make sure that the `AuthUserFile ` and `Require` variables are set properly.

    That's all!
     
    RoseHosting, Feb 27, 2020 IP
  3. phpUser1023

    phpUser1023 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    hey thanks so much! but one other question for you if you don't mind....all of this stuff is supposed to be done through the server's command line, correct? because this same goal can be accomplished using PHP scripting. I can also do *most* of it through a hosting company's cPanel.
     
    phpUser1023, Feb 27, 2020 IP
  4. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    228
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #4
    Yes, this has to be done through the command line.

    If you have cPanel installed on the server, you can do it through the control panel, as described in cPanel's documentation.
     
    RoseHosting, Feb 27, 2020 IP
  5. phpUser1023

    phpUser1023 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    Rose,

    the instructions for cPanel that you provided to me does *not* do what I need. the reason being is because of what it says:
    I already tried that approach and that can't work. I have many subdirs that are at the same level of the tree and each subdir has to be protected with different passwords. thus, the concept of "protecting each subdir automatically"won't work. so I think I'll go with the command line approach. thanks!
     
    phpUser1023, Feb 27, 2020 IP