DeveloperSide.NET Forums

DeveloperSide.NET => Web.Developer Server Suite Community Edition,
Public Support Forum => Topic started by: jgd12345 on January 02, 2005, 02:33:57 PM



Title: .htaccess Files
Post by: jgd12345 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


Title: .htaccess Files
Post by: Xbot 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.


Title: .htaccess Files
Post by: admin 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


Title: .htaccess Files
Post by: admin 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.


Title: .htaccess Files
Post by: jgd12345 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?


Title: .htaccess Files
Post by: jgd12345 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


Title: .htaccess Files
Post by: admin 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.


Title: .htaccess Files
Post by: jgd12345 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.


Title: .htaccess Files
Post by: admin on January 03, 2005, 06:55:54 PM
What version of the Web-Server Suite are you using?


Title: .htaccess Files
Post by: admin 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.


Title: .htaccess Files
Post by: jgd12345 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.


Title: .htaccess Files
Post by: jgd12345 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


Title: .htaccess Files
Post by: admin 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


Title: .htaccess Files
Post by: whoop 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.


Title: .htaccess Files
Post by: admin 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


Title: uploading remotely to private folder
Post by: pichan916 on April 05, 2005, 04:19:36 PM
nevermind, i found the script code for it.


Title: .htaccess Files
Post by: lincspoacher on November 21, 2005, 04:34:53 PM
I have cleared out an earlier version of the devside package, and loaded the latest self-extracting version.  It recognises .php files fine - but does not show php includes - in IE6 or Firefox.

.htaccess file has this line:

Code:
AddType application/x-httpd-php .html .htm


the web files are in folder www/myweb

httpd.conf changes:
Code:
DocumentRoot "/www/webroot/myweb"

<Directory "/www/webroot/myweb">


Full block of code reads:
Code:

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


<IfModule mod_auth.c>
    <Files ~ "^\.ht">
        Order allow,deny
        Deny from all
    </Files>

    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/private/.htpasswd"
        require valid-user
    </Directory>


php .ini

Code:
doc_root = C:/www/webroot/myweb


Is there anything else I have to look at?

The server is used on my Windows Xp Home SP2 laptop for web-development purposes only.


Title: .htaccess Files
Post by: lincspoacher on November 21, 2005, 08:17:00 PM
OK, I solved the problem for my purposes by adding
Code:
AddType application/x-httpd-php .php .html .htm

to the httpd.conf file.

Since this will work with my web under development, and I know the .htaccess file hacks it on the domain server, that'll do me.


Title: .htaccess Files
Post by: Jorge on November 22, 2005, 02:52:10 PM
Quote from: "lincspoacher"
OK, I solved the problem for my purposes by adding
Code:
AddType application/x-httpd-php .php .html .htm

to the httpd.conf file.

Since this will work with my web under development, and I know the .htaccess file hacks it on the domain server, that'll do me.


.html and .htm files should never be passed through php...

.php files (optionaly .phps, .phtml, .php3) schould be passed to php.

If your using php code in a htm(l) you should consider renaming the file!

passing all .htm(l) files will give a considerable slow down of the webserver.


Title: .htaccess Files
Post by: lincspoacher on November 22, 2005, 09:10:49 PM
I am doing that for all new files - but for existing ones I don't want to loose the .htm file extensions because of search engines - and bookmarks.  Almost every .htm  file now has php includes - which makes updating navbars and so forth very easy.

I haven't seen perceptible delays, on the active site's host server, caused by it.


Title: .htaccess Files
Post by: Jorge on November 23, 2005, 10:41:12 AM
You could use rewrite to redirect the .htm files to there php counterparts.