Forum Moderators: phranque

Message Too Old, No Replies

Securing a page in Apache

Problem with login-required page in subdirectory

         

copper304

2:03 pm on Nov 18, 2009 (gmt 0)

10+ Year Member



Hello all.. I am a very noob to apache web server.
so please be kind..:)
anyway. I have been working on my personal web server for about 3 to 4 weeks. I got apache 2.2 installed and running. I was able to make all my web pages and I even got them all up and running also. Well then I had someone tell me that they wanted a members section only. So I went and moved one of my pages to a sub folder and made a .htaccess file. I put that file along with the moved .html page into this subfolder. well after 2 weeks of fighting with the .htaccess file I finely got the password box to pop up. So I thought I had made head way. Well the page wont come up...:( so now I feel like I am back to square one. What am I doing wrong. I thought it was my navigation bar on my main page or maybe the sub html page. So I moved one of my other pages into a sub folder and changed the link on the navigation bar.. nothing. it wont work either. and that sub folder does not have a .htaccess file in it. So I am lost now. Can someone please help. I have been looking and looking online but cant find the answer. following is what I have in the .htaccess file:

AuthType Basic
AuthName "sub folder name"
AuthUserFile /password file/my password file
Require User Me

and this is what I put in my httpd.config just below the (the following lines prevent .htaccess) section in my .config

<Directory "htdocs/sub folder name/"
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all

and I have changed this entry a couple of times with the options, without sometimes. and nothing seems to work. Oh and yes I do have the AllowOverride all in my root. I seem to think that what I am trying to do is very simple, I just am not getting it.. Thank you for any and all help..

jdMorgan

4:06 pm on Nov 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What does "the page won't come up" mean? -- What do you see after entering your username and password?

Also, how did you generate the encrypted-password file?

Jim

copper304

2:50 am on Nov 19, 2009 (gmt 0)

10+ Year Member



Thank you for responding. after I enter the user ID and password it looks like it is attempting to retrive the new page, but I get a 500 Internal Server Error.

and I used the htpasswd program that came with the 2.2

jdMorgan

11:53 am on Nov 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> 500 Server Error.

What information appears about this error in your server error log file?

BTW, in case it was not just a cut-and-paste error, the .config code above may have several problems in it. Just what is shown above should be:


<Directory "htdocs/sub folder name/">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
# ... any additional code ...
</Directory>

Jim

copper304

9:39 pm on Nov 19, 2009 (gmt 0)

10+ Year Member



Ok after getting your message I looked over the Directory and I did have everything in my .config file correct. I just didn't type it in forum correctly. and second, as far as my error log it responded by this:

"GET /Sub%20Folder/****.html HTTP/1.1" 401 401
"GET /favicon.ico HTTP/1.1" 404 209
"GET /Sub%20Folder/****.html HTTP/1.1" 500 538

I put the ****.html but it is actually the web page I made.. I am not sure if I should be using the actual names of this.. Again, I am a noobie to Apache. And thank you so much for your help..

jdMorgan

2:03 am on Nov 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Those entries are from your access log, not your error log. Take a look at the error log, as it will often tell you exactly what the problem is... or at least give you a very strong hint.

You can use real or example page names -- just don't use any that are so unique that they only appear on your site, or any that might offend anyone. It'd probably be a good idea to avoid 'pointing' anyone to your site until you get the password protection working properly... ;)

Jim

copper304

11:08 am on Nov 20, 2009 (gmt 0)

10+ Year Member



Well after trying to open a full error log.. hehe. I finely got my log to open and tell me what was wrong. Thank you. It is my password file. It cant open that file. But i am making the password file the way the tutorial tells me to. So what am I doing wrong? I am using the htpasswd program.

jdMorgan

3:02 pm on Nov 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is likely that the path you gave in the AuthUserFile directive is incomplete or incorrect. This needs to be a full server filepath -- including the full path all the way from the Apache install directory to the password file (or a full system filepath).

Jim