Folder Protect with .htaccess! Not Work?

amn

New Member
Hi,
Im try protect one folder on server with .htaccess and .htpasswd

.htaccess file:
AuthUserFile /home/user/.htpasswd
AuthName "Site Name"
AuthType Basic

< Limit GET>
require user TEST
< /Limit>

and

.htpasswd
TEST:eTKYgBHzssilA


Im upload .htaccess in the protected folder...
and upload .htpasswd in location /home/user/


But i try in browser open protected folder like htxp://www.test.com/xxx/
but not work... firefox redirecting me to index page...

What is problem this is a my .htaccess file in root:

# Comment the following line (add '#' at the beginning)
# to disable mod_rewrite functions.
# Please note: you still need to disable the hack in
# the vBSEO control panel to stop url rewrites.
RewriteEngine On

# Some servers require the Rewritebase directive to be
# enabled (remove '#' at the beginning to activate)
# Please note: when enabled, you must include the path
# to your root vB folder (i.e. RewriteBase /forums/)
#RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.mysite\.com
RewriteRule (.*) http://www.mysite.com/$1 [L,R=301]

RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron)
RewriteRule ^((archive/)?(.*\.php(/.*)?)?)$ vbseo.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
RewriteEngine On
RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
 
First, on 99% of the servers I have been on, the path would be: /home/user/public_html/.htaccess

That is if you are wanting the whole site to have the authentication. But if it is just a folder on the site it would be /home/user/public_html/folder/.htaccess

Possibly your path is just incorrect
 
yea path is /home/user/public_html/
but this /home/user/ is Unavailable location for visitors...this is a best solutions for .htpasswd file...

Yes im try put /home/user/public_html/.htpasswd
and
/home/user/public_html/protected folder/.htaccess

but not work...
 
On my file structure, this is how it would look if I were trying to protect public_html folder:

/home/myaccount
-/.htpasswds
--/public_html/passwd <-this is the file with the encoded password(s)

/home/myaccount
-/public_html/.htaccess <-htaccess file

My .htaccess file looks like this:

Code:
<Files .htaccess>
order allow,deny
deny from all
</Files>
AuthType Basic
AuthUserFile "/home/myaccount/.htpasswds/public_html/passwd"
require valid-user
AuthName "Protected public_html"

Maybe yours isn't working because you're missing the "s. Hope that helps.
 
Grinderhand said:
On my file structure, this is how it would look if I were trying to protect public_html folder:

/home/myaccount
-/.htpasswds
--/public_html/passwd <-this is the file with the encoded password(s)

/home/myaccount
-/public_html/.htaccess <-htaccess file

My .htaccess file looks like this:

Code:
<Files .htaccess>
order allow,deny
deny from all
</Files>
AuthType Basic
AuthUserFile "/home/myaccount/.htpasswds/public_html/passwd"
require valid-user
AuthName "Protected public_html"

Maybe yours isn't working because you're missing the "s. Hope that helps.

You should always upload/create the .htpasswd file outside of public_html for security reasons

ie:
home/user/.htpasswd
 
Back
Top