DeveloperSide.NET Forums

DeveloperSide.NET => Anything else goes here => Topic started by: bigjoe11a on October 01, 2007, 02:29:40 AM



Title: Htaccess
Post by: bigjoe11a on October 01, 2007, 02:29:40 AM
Hi! where can I get help with .htaccess. for WD

1) I need to know how to deney access to directories
2) How can I get my PHP scripts to see another directory

Joe


Title: Re: Htaccess
Post by: admin on October 01, 2007, 02:03:02 PM
1. You should have .htaccess enabled with something like...

Code:
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>

AccessFileName .htaccess

2. You need to allow whichever directory blocks to allow specific levels of .htaccess override with...
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

3. Assuming you have 'AllowOverride Info' set, you can restrict access to a dir with .htaccess file similar to...
Code:
order deny,allow
deny from all
allow from xx.xx.xx.xx


Title: Re: Htaccess
Post by: bigjoe11a on October 01, 2007, 02:11:09 PM
1. You should have .htaccess enabled with something like...

Code:
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>

AccessFileName .htaccess

2. You need to allow whichever directory blocks to allow specific levels of .htaccess override with...
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

3. Assuming you have 'AllowOverride Info' set, you can restrict access to a dir with .htaccess file similar to...
Code:
order deny,allow
deny from all
allow from xx.xx.xx.xx

ok, Thanks, where do I add the code too. Is there a file I add it too. Or??

I never done this before.

Joe



Title: Re: Htaccess (UPDATE)
Post by: bigjoe11a on October 01, 2007, 02:37:10 PM
I fount this option in my httpd.conf file

Code:
IndexIgnore .HTaccess
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>

I hope that helps you so that you can help me



Title: Re: Htaccess
Post by: admin on October 01, 2007, 02:48:10 PM
Put the 1st in httpd.conf - global, put the second in a specific directory block under httpd.conf.


Title: Re: Htaccess
Post by: bigjoe11a on October 01, 2007, 03:17:56 PM
Put the 1st in httpd.conf - global, put the second in a specific directory block under httpd.conf.

The first part is done. I don't get the 2nd part

do you mean
apache22/conf/httpd.conf file and path of httpd.conf
apache22/ you mean the .htaccess file should go in the apache22 directory

Or do you mean some thing else


Title: Re: Htaccess
Post by: admin on October 01, 2007, 03:23:03 PM
You need to put 'AllowOverride Info' into a '<Directory xxx'> block under httpd.conf. Maybe the '/' block, maybe the '/www/webroot' block, etc...


Title: Re: Htaccess
Post by: bigjoe11a on October 01, 2007, 03:36:30 PM
You need to put 'AllowOverride Info' into a '<Directory xxx'> block under httpd.conf. Maybe the '/' block, maybe the '/www/webroot' block, etc...

Ok, theres both of them in my httpd.conf file

Both of them say
Code:
AllowOverride None

I take it that it shouldn't say that. what should it say

Joe


Title: Re: Htaccess
Post by: admin on October 01, 2007, 03:49:03 PM
Put it under the webroot block.


Title: Re: Htaccess
Post by: admin on October 01, 2007, 03:50:17 PM
Make sure to restart Apache for changes to take effect. Also note that if you want to use more than 'order allow/deny' in .htaccess files, you will need to adjust 'AllowOverride' accordingly. Set it to 'All' for max override.


Title: Re: Htaccess
Post by: bigjoe11a on October 01, 2007, 04:12:24 PM
Make sure to restart Apache for changes to take effect. Also note that if you want to use more than 'order allow/deny' in .htaccess files, you will need to adjust 'AllowOverride' accordingly. Set it to 'All' for max override.

Thank You. How my browser is tring to read the .htaccess file. It's just that I keep getting an internal server error. It says that the

The server encountered an internal error or misconfiguration and was unable to complete your request.

I get the idea that its not reading the .htaccess files that I have in the directory that I'm trying to protect

any way. Heres the samples that I got from a google.com search

Code:
.htaccess
AuthName "Fileboss"
Authtype Basic
AuthUserFile /fileboss/data/ .htaccess
Requires Valid-User

.htpasswd
username:password


As far as I know it should read it. SO what I'm I doing wrong

Joe


Title: Re: Htaccess
Post by: admin on October 01, 2007, 04:30:57 PM
I'm sure it's reading it, its just that what its reading is not right. Check the private.conf for an example of what you are trying to do.


Title: Re: Htaccess
Post by: bigjoe11a on October 01, 2007, 04:51:18 PM
I'm sure it's reading it, its just that what its reading is not right. Check the private.conf for an example of what you are trying to do.

What I did was I copy the info from the private.conf file and copied it into the .htaccess file that I have in that directory. All I did was change some of the directories around and I still get a Internal Server Error. So Its trying to read.

Here my new code
Code:
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_user_module modules/mod_authz_user.so

<IfModule authn_file_module>
Alias /data "/www/webroot/fileboss/data"

<Directory "/www/webroot/fileboss/data">
Options Indexes FollowSymLinks
AllowOverride All

Order allow,deny
Allow from all

AuthType Basic
AuthName "FileBoss"
AuthUserFile "/www/webroot/fileboss/data/.htpasswd"
require valid-user
</Directory>
</IfModule>

Again Thanks for your help

Joe


Title: Re: Htaccess
Post by: admin on October 01, 2007, 04:58:11 PM
Check \www\Apache22\logs\error.log


Title: Re: Htaccess
Post by: bigjoe11a on October 01, 2007, 05:15:14 PM
Check \www\Apache22\logs\error.log

Its say Invalid Auth File Type .htpsswd
and
LoadModule not allowed here.

Ok, So I commented the load Modules. How How do I fix the Auth File Type



Title: Re: Htaccess UPdate
Post by: bigjoe11a on October 01, 2007, 05:43:28 PM
Ok, The only error I'm getting now is

Alias not allowed here

How do I fix that


Title: Re: Htaccess
Post by: admin on October 01, 2007, 05:58:07 PM
You don't copy the entire private.conf file into the .htaccess file. Just some parts of it.


Title: Re: Htaccess
Post by: bigjoe11a on October 01, 2007, 06:03:59 PM
You don't copy the entire private.conf file into the .htaccess file. Just some parts of it.

Yes, I took out the load modules parts. and the only error I get now is..

 Alias Not allowed here



Title: Re: Htaccess
Post by: bigjoe11a on October 03, 2007, 04:15:05 AM
So can you tell me how to fix this



Title: Re: Htaccess
Post by: admin on October 03, 2007, 12:59:11 PM
I'm not sure what you are trying to do. How are you trying to restrict access, via IP, via user/password combo. What dirs?


Title: Re: Htaccess
Post by: bigjoe11a on October 03, 2007, 01:07:35 PM
I'm not sure what you are trying to do. How are you trying to restrict access, via IP, via user/password combo. What dirs?

this is an area on my server that I want to password protect. Its apart of a new project that I'm working on. I copied and pasted the code like you said. and now the only error I get is Alias Not allowed here. It should be asking me for a user name and password.

How do I fix the error of Alias not allowed here.

Here my new code
Code:
<IfModule authn_file_module>
Alias /data/ "/www/webroot/fileboss/data"  //This is where the error is

<Directory "/www/webroot/fileboss/data">
Options Indexes FollowSymLinks
AllowOverride All

Order allow,deny
Allow from None

AuthType Basic
AuthName "Admin"
AuthUserFile ".htpasswd"
require valid-user
</Directory>
</IfModule>



Title: Re: Htaccess
Post by: admin on October 03, 2007, 01:45:41 PM
You don't put alias, nor directory blocks, into .htaccess files.

And I don't think 'allow from none' is valid.

You should go here...
http://httpd.apache.org/docs/2.2/


Title: Re: Htaccess
Post by: bigjoe11a on October 03, 2007, 03:50:35 PM
You don't put alias, nor directory blocks, into .htaccess files.

And I don't think 'allow from none' is valid.

You should go here...
http://httpd.apache.org/docs/2.2/

The doc's on the apache web site just don't cover every thing I need to know. See I can block access to that directory like I did my other directories, It just that this I want access to from any where



Title: Re: Htaccess
Post by: admin on October 03, 2007, 04:27:40 PM
What you are trying to do just consists of putting this into an .htaccess file...
Code:
Order allow,deny
Allow from all

AuthType Basic
AuthName "Private Access"
AuthUserFile "/www/private/.htpasswd"
require valid-user

With the path updated to point to the right .htpasswd file. This assume you have created one, filled it in correctly, and have .htaccess enabled under httpd.conf and the correct AllowOverride set for the specific directory.


Title: Re: Htaccess
Post by: bigjoe11a on October 03, 2007, 06:57:57 PM
What you are trying to do just consists of putting this into an .htaccess file...
Code:
Order allow,deny
Allow from all

AuthType Basic
AuthName "Private Access"
AuthUserFile "/www/private/.htpasswd"
require valid-user

With the path updated to point to the right .htpasswd file. This assume you have created one, filled it in correctly, and have .htaccess enabled under httpd.conf and the correct AllowOverride set for the specific directory.

Thank You. That works. and thats what I wanted to know. Its just that I'm having a hard time under standing you.

Thanks
Joe