Hello,
I have a website, and i would like to have a section for members only.
I would like to know how to protect my directory for members only?
Protect Folders Directory Files With Apache .htaccess
Protect Folders Directory Files With Apache .htaccess
Protect Folders Directory Files With Apache .htaccess
Post Description:
Post Tags: protect, folders, directory, files, with, apache, htaccess
This Post Has Been Viewed 907 Times Since Tue Aug 15, 2006 5:42 pm Posted By hostman with 1 replies
Post Description:
Post Tags: protect, folders, directory, files, with, apache, htaccess
This Post Has Been Viewed 907 Times Since Tue Aug 15, 2006 5:42 pm Posted By hostman with 1 replies
| Protect Folders Directory Files With Apache .htaccess |
Leave Your Comments [ dejar commentarios ]
Comments and replies About Protect Folders Directory Files With Apache .htaccess
:: 1 :: #83 - Reply By hostman On Tue Aug 15, 2006 5:55 pm
You need to create two files: .htpasswd and .htaccess
For the purpose of this tutorial, I will be protecting my file called "private.html" in the "proctected" directory which the path is going to be: /var/www/html/protected/private.html.
My username will be admin and my password will be lets say Pa$$w0rd
Username: admin
Password: Pa$$w0rd
So the .thpasswd file will look something like this:
Code:
admin:Xwe3k4OzAsd3@.Wag
Now, The second file to create is called: .htaccess and it would look like this:
Code:
After you have saved the files, upload both files to the /var/www/html/protected/ directory (or whatever directory for your site)
When you try to access the proctected directory with your browser from the internet, you will be prompted to provide a username and password:
THIS IS HOW IT LOOKS WITH FIREFOX:
THIS IS HOW IT LOOKS WITH WINDOWS INTERNET EXPLORER:
If you tried it and it doesn't work, then check the apache configuration file:
httpd.conf to make sure AllowedOveride is set to "All" instead of "None"
If you have a Redhat Distribution (like Fedora) you can find the httpd.conf file at /etc/httpd/conf/httpd.conf.
LOCATE:
Code:
CHANGE TO
Code:
LOCATE:
Code:
CHANGE TO:
Code:
If you are using a shell command to change these options, you can do it with vi. But I prefer to use nano, its much easier. execute the following command:
Code:
For the purpose of this tutorial, I will be protecting my file called "private.html" in the "proctected" directory which the path is going to be: /var/www/html/protected/private.html.
My username will be admin and my password will be lets say Pa$$w0rd
Username: admin
Password: Pa$$w0rd
So the .thpasswd file will look something like this:
Code:
admin:Xwe3k4OzAsd3@.Wag
Now, The second file to create is called: .htaccess and it would look like this:
Code:
AuthType Basic
AuthName "Members Only"
AuthUserFile AuthType Basic
AuthName "Members Only"
AuthUserFile /var/www/html/protected/.htpasswd
<limit GET PUT POST>
require valid-user
</limit>
AuthName "Members Only"
AuthUserFile AuthType Basic
AuthName "Members Only"
AuthUserFile /var/www/html/protected/.htpasswd
<limit GET PUT POST>
require valid-user
</limit>
After you have saved the files, upload both files to the /var/www/html/protected/ directory (or whatever directory for your site)
When you try to access the proctected directory with your browser from the internet, you will be prompted to provide a username and password:
THIS IS HOW IT LOOKS WITH FIREFOX:
THIS IS HOW IT LOOKS WITH WINDOWS INTERNET EXPLORER:
If you tried it and it doesn't work, then check the apache configuration file:
httpd.conf to make sure AllowedOveride is set to "All" instead of "None"
If you have a Redhat Distribution (like Fedora) you can find the httpd.conf file at /etc/httpd/conf/httpd.conf.
LOCATE:
Code:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
Options FollowSymLinks
AllowOverride None
</Directory>
CHANGE TO
Code:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
Options FollowSymLinks
AllowOverride All
</Directory>
LOCATE:
Code:
#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride None
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride None
CHANGE TO:
Code:
#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride All
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride All
If you are using a shell command to change these options, you can do it with vi. But I prefer to use nano, its much easier. execute the following command:
Code:
nano /etc/httpd/conf/httpd.conf


