DeveloperSide.NET Forums
July 05, 2020, 01:32:22 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: .htaccess Files  (Read 35565 times)
0 Members and 1 Guest are viewing this topic.
jgd12345
Member
*
Posts: 12


View Profile
« on: January 02, 2005, 02:33:57 PM »

Hi, how do you configure your server to allow the use of these.  I wish to use them in the sub directory of the webroot directory.  I imagine it's something around:

Code:

#####For Apache::ASP examples
#
# AccessFileName .htaccess
#
# <Files ~ "^\.htaccess$">
# order allow,deny
# deny from all
# </Files>
#
<Directory "/www/webroot/asp-example">
order deny,allow
deny from all
# allow from 127.0.0.1
# Options FollowSymLinks
# AllowOverride All
</Directory>
#


In the config file but I've tried a few different things and nothing seems to work.  I'd be greatful for your help.  Thanks
Logged
Xbot
Member
*
Posts: 28


View Profile
« Reply #1 on: January 02, 2005, 06:10:41 PM »

I'll use my /private example to show you how.

Code:

Alias /private "/www/private"
<Directory "/www/private">
<IfModule mod_autoindex.c>
Options Indexes
</IfModule>

Order allow,deny
Allow from all

AuthType Basic
AuthName "Private Access"
AuthUserFile "/www/pwds/htpasswd"
require valid-user
</Directory>


Try that. Where AuthUserFile is, use the directory of your htpasswd file. For the directory use the directory that you want protected. Alias do the same.

That should do it.


EDIT: I guess this isn't what you needed. Oh well, someone might be able to use it.
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #2 on: January 02, 2005, 06:26:08 PM »

Add...
Code:

AccessFileName .htaccess
 
<Files ~ "^\.htaccess$">
  order allow,deny
  deny from all
</Files>


Modify code block (insert 'AllowOverride All')...
Code:

<Directory "/www/webroot">
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>


You will need to create a file '.htaccess' under the sub dir of webroot that you are intrested in.
After making changes to httpd.conf, make sure to restart Apache.
Also check \www\Apache2\logs\error.log

http://httpd.apache.org/docs-2.0/mod/core.html#accessfilename
http://httpd.apache.org/docs-2.0/mod/core.html#allowoverride
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #3 on: January 02, 2005, 09:29:51 PM »

You also need to make sure that whatever directory you created under webroot, has its access permissions set under httpd.conf.  And that no other config options, that you might have set for that dir, will override the above code.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
jgd12345
Member
*
Posts: 12


View Profile
« Reply #4 on: January 02, 2005, 11:07:47 PM »

Hi, I changed it to:

Code:

#####For Apache::ASP examples
#
AccessFileName .htaccess

<Files ~ "^\.htaccess$">
order allow,deny
deny from all
</Files>
#
<Directory "/www/webroot">
AllowOverride All
order deny,allow
allow from all
# allow from 127.0.0.1
# Options FollowSymLinks
</Directory>
#
#####End Apache::ASP examples


and restarted apache but now I get the error:

Quote

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

Please contact the server administrator, admin@yourdomain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


everytime I go to a page.  Any ideas?
Logged
jgd12345
Member
*
Posts: 12


View Profile
« Reply #5 on: January 02, 2005, 11:20:47 PM »

After abit of trial and error I found AllowOverride All this to be causing the problem.  When I remove this the pages load fine but the htaccess files still don't work.

If it's any help here's my httd.conf file (i know it could be dangerous to post this but it's only for testing purposes)

Code:

old
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #6 on: January 02, 2005, 11:38:30 PM »

What does 'Apache::ASP' have to do with '.htaccess' files?

And why are you using the 'Apache::ASP' setup code in your httpd.conf?

If you only need what you have stated (htaccess), remove all the changes you have made to httpd.conf, and read my post above.

If you are trying to set up Apache::ASP, please educate yourself on what it is, and understand that you have to have it installed first -- the changes you make to httpd.conf is only to configure it.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
jgd12345
Member
*
Posts: 12


View Profile
« Reply #7 on: January 03, 2005, 06:51:03 PM »

Hi, the config file I am using came automatically with it.  I don't have a clue what it all means just starting out.
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #8 on: January 03, 2005, 06:55:54 PM »

What version of the Web-Server Suite are you using?
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #9 on: January 03, 2005, 06:59:31 PM »

The only version that came with Apache::ASP is about six months old.

Either way, what you are trying to do has nothing to do with what you are asking.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
jgd12345
Member
*
Posts: 12


View Profile
« Reply #10 on: January 03, 2005, 07:02:50 PM »

Hi, I think I understand what I gotta do just testing a few different things.  The config file come with one of the pre built packs available on this site.
Logged
jgd12345
Member
*
Posts: 12


View Profile
« Reply #11 on: January 07, 2005, 04:32:21 AM »

Hi, I changed it to the following but I'm still getting the error message "Internal Server Error" but when I upload the same .htaccess file to my server it works fine.  This suggests to me there is a problem with the httpd.conf file still:

Code:

###*********************************************************
###*  DeveloperSide.NET                                    *
###*  http://www.devside.net                               *
###*  admin@devside.net                                    *
###*********************************************************


Listen 80
ServerRoot "/www/Apache2"
DocumentRoot "/www/webroot"

ServerName localhost:80
ServerAdmin admin@yourdomain.com

ServerSignature On
ServerTokens Full

DefaultType text/plain
AddDefaultCharset ISO-8859-1

UseCanonicalName Off

HostnameLookups Off

ErrorLog logs/error.log
LogLevel error

PidFile logs/httpd.pid

Timeout 300

KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15


<IfModule mpm_winnt.c>
ThreadsPerChild 250
MaxRequestsPerChild 0
</IfModule>


LoadModule access_module modules/mod_access.so
#LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
#LoadModule asis_module modules/mod_asis.so
#LoadModule auth_module modules/mod_auth.so
#LoadModule auth_anon_module modules/mod_auth_anon.so
#LoadModule auth_dbm_module modules/mod_auth_dbm.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule dir_module modules/mod_dir.so
#LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule file_cache_module modules/mod_file_cache.so
LoadModule headers_module modules/mod_headers.so
#LoadModule imap_module modules/mod_imap.so
#LoadModule include_module modules/mod_include.so
LoadModule info_module modules/mod_info.so
#LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule negotiation_module modules/mod_negotiation.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule speling_module modules/mod_speling.so
LoadModule status_module modules/mod_status.so
#LoadModule unique_id_module modules/mod_unique_id.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
<IfDefine SSL>
LoadModule ssl_module modules/mod_ssl.so
</IfDefine>
LoadModule deflate_module modules/mod_deflate.so
LoadModule perl_module modules/mod_perl.so
LoadModule php4_module /www/php/php4apache2.dll


<Directory />
<IfModule mod_deflate.c>
# AddOutputFilterByType DEFLATE text/html text/plain text/xml
# The above does not seem to work under win32 100%, we will use this instead...
SetOutputFilter DEFLATE
<IfModule mod_headers.c>
Header append Vary User-Agent
</IfModule>
</IfModule>
Options FollowSymLinks
AllowOverride None
order deny,allow
deny from all
</Directory>


<Directory "/www/webroot">
AllowOverride All
Order allow,deny
Allow from all
</Directory>


#### .htaccess File Configuration
AccessFileName .htaccess

<Files ~ "^\.htaccess$">
order allow,deny
deny from all
</Files>


<IfModule mod_cgi.c>
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ "/www/cgi-bin/"
</IfModule>

<Directory "/www/cgi-bin">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</IfModule>


#####For mod_perl Hello example, \www\perl\site\lib\Apache\Hello.pm
#
PerlModule Apache::Hello
<Location /hello>
SetHandler modperl
PerlResponseHandler Apache::Hello
</Location>
#
#####End mod_perl Hello example


#####For Apache::ASP examples
#
# AccessFileName .htaccess
#
# <Files ~ "^\.htaccess$">
# order allow,deny
# deny from all
# </Files>
#
<Directory "/www/webroot/asp-example">
order deny,allow
deny from all
# allow from 127.0.0.1
# Options FollowSymLinks
# AllowOverride All
</Directory>
#



#####Apache::ASP setup
#
<IfModule mod_perl.c>
PerlModule Apache::ASP
<Files ~ (\.asp)>
SetHandler perl-script
PerlHandler Apache::ASP
PerlSetVar Global .
PerlSetVar StateDir /tmp/asp
</Files>
</IfModule>
#
#####End Apache::ASP setup


<Directory "/www/webroot/phpMyAdmin">
order deny,allow
deny from all
allow from 127.0.0.1
</Directory>

<Directory "/www/webroot/stats">
order deny,allow
deny from all
allow from 127.0.0.1
</Directory>

<IfModule mod_log_config.c>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog logs/access.log combined
<IfModule mod_deflate.c>
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate.log deflate
</IfModule>
</IfModule>

<IfModule mod_dir.c>
DirectoryIndex index.html index.php index.asp
</IfModule>

<IfModule mod_mime.c>
TypesConfig conf/mime.types
AddType application/x-tar .tgz
AddType application/x-rar-compressed .rar
<IfModule sapi_apache2.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
</IfModule>

<IfModule mod_setenvif.c>
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully
<IfModule mod_deflate.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
</IfModule>

<IfModule mod_status.c>
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</IfModule>

<IfModule mod_info.c>
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</IfModule>

<IfModule mod_ssl.c>
Include conf/ssl.conf
</IfModule>


I'd appreciate any help.  Thanks
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #12 on: January 07, 2005, 05:31:39 AM »

What are the contents of your .htaccess file?

Also post the contents of file \www\Apache2\logs\error.log
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
whoop
Member
*
Posts: 8


View Profile
« Reply #13 on: March 08, 2005, 11:54:02 AM »

Hi all I need a quick bit of help.
I want to protect a sub dir of the root dir
eg c:\www\webroot\myfile
i want to set my htacces file to allow local ip's (pcs on local network) un contested access and remote ips access after username and password check.
I don't know where to put my htaccess and ht password files.
do i need to put the htacces file in the "myfile" dir or in the webroot dir or somewhere in the www dir?
can someone create an example for me just standard htaccess and password files and i will amend as i need.
thanks.
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #14 on: March 08, 2005, 07:53:33 PM »

You put it under the C:\www\webroot\myfile dir.

This will get you half the way...
http://www.devside.net/web/config/windows/password
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!