Forum Moderators: phranque

Message Too Old, No Replies

Help me modify .htaccess plz

restrict access to to admin for myself

         

bucknasty

1:23 pm on Jul 27, 2007 (gmt 0)

10+ Year Member



Hello Again,
My problem today is that i need to set up access to my admin folder to except my "username" and "password" and to disallow others. I'm running on windows XP -w Apache. My admin folder already had both a .htaccess & .htpasswd files in it, so I didn't create a new one. I first changed my http.conf file to "AllowOverride AuthConfig". Next i added this to the http.conf:

#This is for implementing authentication for users!
<Directory "c:/Program Files/Apache/Apache Group/htdocs/""/admin/.htpasswd">
Order allow,deny
Allow from all
</Directory>
#End of authentication configuration"

Then I used the precompiled .htpasswd wich already has my username and password in it. When I went to my browser and typed in my username & password, they didn't work, I got denied entry. My error log says: user admin not found /""/index.php. Can someone explain to me what this really means:

#This is for implementing authentication for users!
<Directory /opt/web/html> (what is the crap?)
Order allow,deny
Allow from all
</Directory>
#End of authentication configuration

I cannot figure out how to do this, plz help?

bucknasty

4:52 pm on Jul 27, 2007 (gmt 0)

10+ Year Member



Is there anyone that can help me out plz?

g1smd

7:00 pm on Jul 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<Directory "c:/Program Files/Apache/Apache Group/htdocs/""/admin/.htpasswd">

This should have a path defined from the server root, not a full path including drive letter. Additionally, the double "" quotes in the middle is not valid.

<Directory /opt/web/html>

That is the /html folder inside the /web folder inside the /opt folder. Change that to reflect the path you are wanting to set up access control for.

.

This is what I have inside the .htaccess file inside the /public_html/foldername/ folder for one site I look after. You need to define the full path here:

AuthUserFile /home/user12345/public_html/foldername/.htpasswd
AuthName "The Web Site"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>

bucknasty

8:34 pm on Jul 27, 2007 (gmt 0)

10+ Year Member



Thanks for taking the time to help me. I'm still not understanding what exactly it is that I need to do. This is what I did:

this is what's in my http.conf

#This is for implementing authentication for users!
<Directory "/htdocs/nichecreator/admin/.htpasswd">
Order allow,deny
Allow from all
</Directory>
#End of authentication configuration

this is my .htaccess:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /htdocs/nichecreator/.htpasswd
AuthGroupFile /dev/null
require valid-user

this is my .htpasswd

admin:mypassword

my error log says'

user admin not found: /nichecreator/index.php

Do I not have permissions setup for apache to read my .htpasswd file? Please put what needs to go where here so I can get some sleep. Thanks

P.S. This was my original .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [S=44]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=44]
RewriteRule ^(.*)$ index.php?k=$1

This seemed to be to hard to figure out so I went with the above stuff that I read from a book. Someone please help correct my mistakes? Thanks

g1smd

9:01 pm on Jul 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> AuthUserFile /htdocs/nichecreator/.htpasswd <<

Nearly.

It is likely that the path is actually something more like:

AuthUserFile /something/username/whatever/htdocs/nichecreator/.htpasswd

bucknasty

9:28 pm on Jul 27, 2007 (gmt 0)

10+ Year Member



If I'm working from my C/drive Program files, then if I used c:/Program Files/Apache Group/Apache/htdocs/nichecreator/admin/.htaccess? would this be correct? I have a .htaccess folder in my (nichecreator folder) and another in my (admin folder). Am I supposed to change the "AuthUserFile" for both? Also do I put the same path in my http.config file? Thanks

g1smd

9:43 pm on Jul 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you have PHP running? The path you require should be listed if you can run phpinfo.

The path should NOT include any drive letters. the path is relative to the server root, not harddrive root.

bucknasty

9:52 pm on Jul 27, 2007 (gmt 0)

10+ Year Member



Yes I have it installed but I now just cheched it at localhost/php/test.php and the phpinfo page didn't show up like it did before. I'm going to try and backtrack to see if I can resolve that now. Once I fix that, then I let you now what I've found. Thanks

g1smd

10:08 pm on Jul 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The phpinfo.php file (with <?php phpinfo(); ?> inside) needs to be in your web folders.

Don't expose the PHP program folder via website URLs, even if they are on localhost.

bucknasty

10:41 pm on Jul 27, 2007 (gmt 0)

10+ Year Member



Sorry about the misleading info. My phpinfo file was in a folder located in my htdocs directory. Looking over the phpinfo page this is what I've got:

doc_root c:\program files\apache group\apache\htdocs

I removed the changes to my http.config file and deleted my nichecreator directory, so now I'm starting anew. If you don't mind Directing my setup starting from the http.config file, I'd appreciate your help. First do i need to change this"

# First, we configure the "default" to be a very restrictive set of
# permissions.
#
<Directory />
Options FollowSymLinks
AllowOverride None (AllowOverride All)?
</Directory>

And this to:

# 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 (AllowOverride All)?

Thanks for your help.