Apache2Triad Help, Support and Development Forum Index Search Profile Log in to check your private messages Log in Register Memberlist Attachments Statistics Crew/Ranks Archive
 custom error pages and directory browsing?
Google
Post new topic Reply to topic
Author Message
furious angel
 
 


Joined: 21 Jul 2006
Posts: 16

PostPosted: Mon Nov 13, 2006 6:52 am Reply with quoteBack to top

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
View user's profileSend private message
Joshua Meadows (DemoRic)
support
support


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

PostPosted: Tue Nov 14, 2006 12:24 am Reply with quoteBack to top

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
View user's profileSend private messageYahoo MessengerICQ Number
furious angel
 
 


Joined: 21 Jul 2006
Posts: 16

PostPosted: Tue Nov 14, 2006 2:04 am Reply with quoteBack to top

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
View user's profileSend private message
Joshua Meadows (DemoRic)
support
support


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

PostPosted: Wed Nov 15, 2006 12:08 am Reply with quoteBack to top

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.
View user's profileSend private messageYahoo MessengerICQ Number
furious angel
 
 


Joined: 21 Jul 2006
Posts: 16

PostPosted: Fri Dec 01, 2006 2:48 am Reply with quoteBack to top

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
View user's profileSend private message
Joshua Meadows (DemoRic)
support
support


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

PostPosted: Fri Dec 01, 2006 3:31 pm Reply with quoteBack to top

Quote:
that helper batchfile you wrote is awesome by the way!

Thanks! I'm glad you find it useful. Very Happy

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
View user's profileSend private messageYahoo MessengerICQ Number
Display posts from previous:      
Post new topic Reply to topic


 Jump to:   



View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme
All times are GMT