Search code examples
.htaccessserverhtml.htpasswd

Creating .htpasswd file outside webpage files


I'm working with a webpage that uses a content management system. The webpage belongs my university. We want create a private file with .htaccess and htpasswd.

The problem is I can't figure out how to place the htpasswd file outside the webpage files because I don't have access to the server machine. I need to do that because someone told me it is unsafe to place it within the webpage files. Any ideas?


Solution

  • If you have a shared hosting account for your website, I suggest you connect to it through FTP. In Directadmin as example, you have to put the file in your public_html folder (which is the root directory of your site).

    In case you want to put it outside of the root (as you were asking), place it 1 directory lower (so not in the public_html but before that), and then link it to it.

    In case you lack the permissions to do so, contact your hosting provider, cause he should be able to do it for you (and ask him for the direct path).