Community Support
January 09, 2009, 09:08:59 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Staff List Login Register  
Pages: [1]
  Print  
Author Topic: Can I password-protect directories  (Read 98 times)
whumann
New User
*
Offline Offline

Hosting Plan: Free Hosting
Posts: 2
Referrals: 0


« on: October 01, 2008, 04:55:33 PM »

I registered for free icr38.net hosting and was wondering if I can limit access to certain folders to authorized people, e.g. using .htaccess. If it is possible, what's the path to be used for AuthUserFile?

Wolfram
Logged
whumann
New User
*
Offline Offline

Hosting Plan: Free Hosting
Posts: 2
Referrals: 0


« Reply #1 on: October 05, 2008, 03:35:19 PM »

Allright, answered half of my question myself: Access control using .htaccess is possible. If I place a .htaccess-file in a directory I do get asked for login and password if I try to access this from the web. However, when I enter login and pass, I always get an Error 500 (Internal Server Error). That's no surprise because the "AuthUserFile" line in .htaccess needs an absolute path to the file containing logins and passwords so that a line like this

AuthUserFile htdocs/.htusers   # this does NOT work

needs to fail. So the remaining question is:
What's the absolute path from the server's root to the root of my web-space?

Any help or reply much appreciated!
Wolfram

Logged
Andrew
Byteact/i.create Administrator
Administrator
*****
Offline Offline

Hosting Plan: Premium Hosting
Operating System: Linux
Browser: Opera
Posts: 127
Referrals: 2



« Reply #2 on: October 05, 2008, 04:10:32 PM »

To get your definitive path or absolute server path, upload this in a file called path.php into the directory you're looking to protect...

<?php
echo getcwd();
?>

Then view it in your browser by going to it such as yoursite.example.com/path.php... it should display something like /home/vol#/example.com/user_123456/htdocs/path.php and everything before the path.php bit is your path.

From there use the following format for your .htaccess adjusting where necessary...

Code:
AuthUserFile /home/vol#/example.com/user_123456/htdocs/.htpasswd
AuthGroupFile /dev/null
AuthName "Private Area"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

Then upload .htpasswd into your HTDOCS folder using a format similar to this in which the username is chicken and the password is cheese which is encoded using the encoder linked here: http://home.flash.net/cgi-bin/pw.pl

Code:
chicken:XixxrFOdloHMc

For each user simply add a new entry below the previous one.
Logged

Unsolicited private messages for support issues will go unanswered
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC | Sitemap | Archive Valid XHTML 1.0! Valid CSS!