Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ErrorDocument

Status
Not open for further replies.

steam

ISP
Jul 17, 2000
51
IT
Hello<br><br>Do you know how I could set apache so that any user can have a custom server error doc., simply by placing a html file. No .htaccess files<br><br>Something stating that if in any web directory there is a file named i.e. 404.html or 500.html the server shall use those documents.<br><br>Outside the VirtualHost. I guess in a &lt;Directory&gt;.<br><br>Thanks.
 
Just search in httpd.conf for the line containing ErrorDocument 404. Normally this line is commented out, using Apache's internal error-handling page, but you can uncomment the line and use your own html file (or CGI or whatever) as the error document:<br><br>#ErrorDocument 404 /missing.html<br>#&nbsp;&nbsp;to redirect to local URL /missing.html<br>#ErrorDocument 404 /cgi-bin/missing_handler.pl<br>#&nbsp;&nbsp;N.B.: You can redirect to a script or a document using server-side-includes.
 
The above solution will only make one custom error page for every 404 error on the site. I believe you want each user to have a custom page. Try this... <br><br>If you're up for a little programming, you could do as above but point to a script that looks at the filename requested, extracts the path from it, checks to see if there is a file named &quot;404.html&quot; in that path, and if so, redirects to it. If not, it could recursively move up the path looking for a 404.html until it gets to /home/404.html(depending on how your server is set up). This will give you an appropriate amount of error handling, and all your users have the option of putting these files in their directory. If not, the default will be used.
 
I have studied this point a little more ... I would better use .htaccess files :) The problem is that my server does not allow the creation of any file named .htaccess<br><br>I checked apache configuration file and it seems correct:<br><br>---<br><br>AccessFile .htaccess<br><br>&lt;Directory /&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride All&nbsp;&nbsp;&nbsp;<br>&lt;/Directory&gt;<br><br>---<br><br>Also, there are no restrictions (no AllowOverride) in sub Directories :((<br><br>Any idea?<br><br>Thanks very much.
 
It seems the file .htaccess exists (I can get server errors) but it is hidden, even if I'm logged as root.

 
by default any file with the first letter a . is hidden (even if logged in as root)
you can see the file in the directory by using the -al option for ls or dir
ie

dir -al

will show a verbose listing of all files, including hidden files in your current directory

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top