Apache2Triad Help, Support and Development Forum Index Apache2Triad Help, Support and Development
The apache2triad help , support and development forums
 

custom error pages and directory browsing?
Click here to go to the original topic

 
       Apache2Triad Help, Support and Development Forum Index -> Apache
View previous topic :: View next topic  
Author Message
furious angel



Joined: 21 Jul 2006
Posts: 16

Posted: Mon Nov 13, 2006 6:52 am    Post subject: custom error pages and directory browsing?  

hey,

just wondering how one would go about setting up custom error pages.

eg a 404 error occurs and i want it to go to a different page other than the default.

i need apache config advise on this and anything else that is required as i have no idea where to start.

the other thing is to disable directory browsing altogether on the server. Essentially limiting access to only the pages themselves, no folders or directory views in a web browser

cheers,
ben
Back to top  
Joshua Meadows (DemoRic)



Joined: 29 Dec 2004
Posts: 783
Location: S.E. Kansas

Posted: Tue Nov 14, 2006 12:24 am    Post subject:  

Change your root directory options by removing indexes. Now only folders that you manually give indexes to will show indexing of the folder.
Quote: #htdocs config
<Directory "C:/apache2triad/htdocs">
#Options Indexes FollowSymLinks +Includes ExecCGI

Options FollowSymLinks +Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

For custom error docs you can modify your httpd.conf, or as I prefer use .htaccess

.htaccess custom errors example
Quote: ErrorDocument 400 /error.php?400
ErrorDocument 401 /error.php?401
ErrorDocument 403 /error.php?403
ErrorDocument 404 /error.php?404
ErrorDocument 500 /error.php?500
Back to top  
furious angel



Joined: 21 Jul 2006
Posts: 16

Posted: Tue Nov 14, 2006 2:04 am    Post subject:  

ok so ive changed that line in my httpd.conf thanks for that, ill have to see if its working...

as for the custom error pages, am i right in assuming that

ErrorDocument 400 /error.php?400
ErrorDocument 401 /error.php?401
ErrorDocument 403 /error.php?403
ErrorDocument 404 /error.php?404
ErrorDocument 500 /error.php?500

is just added to the end of the .htaccess file in apache2triadCP folder? or do i make a new .htaccess file in the directory of the site? of course the naming of the files will be changed etc. im just unsure of the syntax and placement.

otherwise, how does one go about changing the httpd.conf file's error documents to point to new files. i tried changing the ErrorDocument 404 listing to something else and it didnt work.

cheers,

ben
Back to top  
Joshua Meadows (DemoRic)



Joined: 29 Dec 2004
Posts: 783
Location: S.E. Kansas

Posted: Wed Nov 15, 2006 12:08 am    Post subject:  

you can copy and paste the quote for the .htaccess and place it in any .htaccess. (typically you'd want to use htdocs' .htaccess file) You don't have to replace your .htaccess contents just append to them.

Any changes to your .htaccess will affect the folder it's in, and all sub folders.
You can think of .htaccess as a mini httpd.conf file. (The httpd.conf is the default conf, .htaccess is for little changes that you don't want in your httpd.conf, or for testing changes.)

Changes in your .ht files are reflected in your servers actions when those folders are accessed. Changes to your httpd.conf requires you to restart the server before they take effect.

For custom errors the syntax is
ErrorDocument ### UrlToFile
so
ErrorDocument 404 /error.php?404
ErrorDocument 404 notfound.htm
ErrorDocument 404 http://mysite/somefolder/error.php?404
ErrorDocument 404 /folder/notfound.htm
are all valid.
Back to top  
furious angel



Joined: 21 Jul 2006
Posts: 16

Posted: Fri Dec 01, 2006 2:48 am    Post subject:  

ok i've been messing around with the .htaccess stuff and i think i get the hang of it.

that helper batchfile you wrote is awesome by the way!

i have 2 questions.

when appending to the .htaccess with error documents, my server returns an error (checked in logs).

.htaccess
Code: Require user myusername
AuthType Basic
AuthName "Restricted Area"
AuthUserFile C:\apache2triad\htdocs\securefolder\.htpasswd
ErrorDocument 404 /errordocument.php?error=404

Note: the .htaccess works save for the last line.

error
Code: C:/apache2triad/htdocs/securefolder/.htaccess: ErrorDocument not allowed here

i think i've done everything right unless httpd.conf is not allowing custom error pages or something?

My next question is how to set up encrypted (ssl) on the folder, i noticed this because the login prompt alerts to an unencrypted transmission. I basically just want to change http to https for that particular directory. I've been looking around the forum but can't seem to find exactly what i am after. This would also be useful for the online forms i have, so i can offer better security for my users. I'm thinking it has something to do with the ssl service and rewriting rules but im a little lost.

can you point me in the right direction?

thanks in advance,

ben
Back to top  
Joshua Meadows (DemoRic)



Joined: 29 Dec 2004
Posts: 783
Location: S.E. Kansas

Posted: Fri Dec 01, 2006 3:31 pm    Post subject:  

Quote: that helper batchfile you wrote is awesome by the way!
Thanks! I'm glad you find it useful. :D

The follwing will change requests for the apache2triadcp to https, you can modify it according to your needs.
Code:    RewriteCond %{REQUEST_URI} ^/+apache2triadcp.*$
   RewriteRule ^/+(.*) https://%{SERVER_NAME}/$1 [R,NC]

As for the errors on you error document path. I've never received that error. However, my custom error docs are in my websites root folder (htdocs) and not in sub folders.

You could add the following to your .htaccess and see if it works then
Code: AllowOverride All
Options +FollowSymLinks +SymLinksIfOwnerMatch
Back to top  
 
       Apache2Triad Help, Support and Development Forum Index -> Apache
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.13 © 2001, 2002 phpBB Group