Protect Folders Directory Files With Apache .htaccess
Posted On Tue Aug 15, 2006 By hostman In Linux wallpaper Hosting forums topics about gallery sites in linux systems Forums
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?
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?
hostman Tue Aug 15, 2006
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:
admin:Xwe3k4OzAsd3@.Wag
Now, The second file to create is called: .htaccess and it would look like this:
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:
CHANGE TO
LOCATE:
CHANGE TO:
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:
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
Related Content
Information
Forums »
Linux wallpaper Hosting forums topics about gallery sites in linux systems »
Protect Folders Directory Files With Apache .htaccess
Linux wallpaper Hosting forums topics about gallery sites in linux systems »
Protect Folders Directory Files With Apache .htaccess
Title: Protect Folders Directory Files With Apache .htaccess
Description: Protect Folders Directory Files With Apache .htaccess
Tags: protect ,folders ,directory ,files ,with ,apache ,htaccess
Info: This Post Has Been Viewed 0 Times Since
Date: Tue Aug 15, 2006
Author hostman Received 1 Replies #380
Date: Tue Aug 15, 2006
Author hostman Received 1 Replies #380
Share
URL: 

Embed: 

To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it
BBCODE:: 

BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
wallpaperama | Wallpapers | Forums | Terms Of Service
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5