You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Kyle <ky...@ccidomain.com> on 2002/04/11 20:09:48 UTC

.htaccess - 404 works, 500 doesn't

I have a site that uses a simple .htaccess file for error document
redirects.  The redirect for 404 errors works, but the one for 500
errors does not.  The server is 1.3.22 and RH7.1.  Here is the entire
.htaccess file:

errordocument 404 /404.htm
errordocument 500 /500.htm

The 404 one works by overriding the default 404 document called out in
the httpd.conf as expected.  But for 500s, you get the default page that
is called out in httpd.conf instead of .htaccess.  Both 404.htm and
500.htm files exist in the same directory with the same owner, same
group, and same permissions (644).

The way my virtual hosts are set up, each virtual host equates to a user
home directory.  If you go to that user's directory, you'll see the
following dirs:
www
cgi-bin

www is the "root" for web domains and I have the following line to use
CGIWrap and make it appear that the cgi-bin is in the user's web area:
   Action cgi-wrapper /cgi-bin/cgiwrap/~www08591

I have copied the .htaccess to the user's home dir, the www dir, and the
cgi-bin dir, and in all cases, the 404.htm gets called, but the 500.htm
does not.

If the Apache site has any help on this, I haven't been able to find
it.  Can anybody offer any hints?

-Kyle

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Kyle <ky...@ccidomain.com>.
Joshua,

Okay, I long suspected a pathing problem, but I was looking on the
virtualhost end, not the wrapper end.  What you're saying makes sense. 
Disappointing that I can't "just do it", but I guess that's the price of
using a wrapper.  :(

Thanks for your help!

-Kyle

Joshua Slive wrote:
> 
> Kyle wrote:
> >>In exactly what directory is that script located?
> >
> >
> > /net/www/wfp86007/cgi-bin/test.pl
> >
> >
> >>And what does the ScriptAlias directive for this site look like?
> >
> >
> > Actual script directives for the virtualhost:
> > ScriptAlias /cgi-bin/ /utils/cgi-bin/
> > AddHandler cgi-wrapper .cgi .pl
> > Action cgi-wrapper /cgi-bin/cgiwrap/~wfp86007
> 
> Now we're really going places.  You're obviously doing something a
> little complicated behind the scenes (using cgi-wrapper) that you
> weren't telling us about.
> 
> When you call test.pl, the program that is actually getting executed by
> Apache is under /utils/cgi-bin.  Since this directory is not covered by
> the .htaccess file, the ErrorDocument does not get applied.
> 
> Now, you can argue about whether or not you think that is appropriate.
> Personally, I think we would see just as many confused people if we did
> it the other way (applied the ErrorDocument on the original document
> rather than the Action target).  So I doubt you'll get much support in
> changing this behavior.
> 
> Now, how do you fix your problem?  I don't really have a perfect and
> easy answer.  One way would be to have a global
> ErrorDocument 500 /globalerrorlocation/500.shtml
> And inside 500.shtml do
> <!--#include virtual="/localerrorlocation/500.shtml" -->
> This should allow each site to have a different 500 error page, but you
> would certainly need to carefully document this for your clients.
> 
> Joshua.
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Joshua Slive <jo...@slive.ca>.
Kyle wrote:
>>In exactly what directory is that script located?
> 
> 
> /net/www/wfp86007/cgi-bin/test.pl
> 
> 
>>And what does the ScriptAlias directive for this site look like?
> 
> 
> Actual script directives for the virtualhost:
> ScriptAlias /cgi-bin/ /utils/cgi-bin/
> AddHandler cgi-wrapper .cgi .pl
> Action cgi-wrapper /cgi-bin/cgiwrap/~wfp86007

Now we're really going places.  You're obviously doing something a 
little complicated behind the scenes (using cgi-wrapper) that you 
weren't telling us about.

When you call test.pl, the program that is actually getting executed by 
Apache is under /utils/cgi-bin.  Since this directory is not covered by 
the .htaccess file, the ErrorDocument does not get applied.

Now, you can argue about whether or not you think that is appropriate. 
Personally, I think we would see just as many confused people if we did 
it the other way (applied the ErrorDocument on the original document 
rather than the Action target).  So I doubt you'll get much support in 
changing this behavior.

Now, how do you fix your problem?  I don't really have a perfect and 
easy answer.  One way would be to have a global
ErrorDocument 500 /globalerrorlocation/500.shtml
And inside 500.shtml do
<!--#include virtual="/localerrorlocation/500.shtml" -->
This should allow each site to have a different 500 error page, but you 
would certainly need to carefully document this for your clients.

Joshua.



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Kyle <ky...@ccidomain.com>.
> In exactly what directory is that script located?

/net/www/wfp86007/cgi-bin/test.pl

> And what does the ScriptAlias directive for this site look like?

Actual script directives for the virtualhost:
ScriptAlias /cgi-bin/ /utils/cgi-bin/
AddHandler cgi-wrapper .cgi .pl
Action cgi-wrapper /cgi-bin/cgiwrap/~wfp86007

-Kyle

Joshua Slive wrote:
> 
> Kyle wrote:
> > New info:  When I put the ErrorDocument 500 directive in the virtualhost
> > section, it catches 500s as expected.  But when I copy the directive
> > from httpd.conf to .htaccess, Apache doesn't use the requested 500 file
> > anymore - it throws the Apache default instead.
> 
> >
> > .htaccess in /net/www/wfp86007 (500 WON'T WORK, 404 WORKS):
> > ErrorDocument 500 /cgi-bin/nice500.cgi
> > ErrorDocument 404 /404.htm
> >
> 
> OK.  Now we're getting a little further.  You said you are testing this
> by executing a faulty cgi script.  In exactly what directory is that
> script located?  And what does the ScriptAlias directive for this site
> look like?
> 
> Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Joshua Slive <jo...@slive.ca>.
Kyle wrote:
> New info:  When I put the ErrorDocument 500 directive in the virtualhost
> section, it catches 500s as expected.  But when I copy the directive
> from httpd.conf to .htaccess, Apache doesn't use the requested 500 file
> anymore - it throws the Apache default instead.

> 
> .htaccess in /net/www/wfp86007 (500 WON'T WORK, 404 WORKS):
> ErrorDocument 500 /cgi-bin/nice500.cgi
> ErrorDocument 404 /404.htm
> 

OK.  Now we're getting a little further.  You said you are testing this 
by executing a faulty cgi script.  In exactly what directory is that 
script located?  And what does the ScriptAlias directive for this site 
look like?

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Kyle <ky...@ccidomain.com>.
New info:  When I put the ErrorDocument 500 directive in the virtualhost
section, it catches 500s as expected.  But when I copy the directive
from httpd.conf to .htaccess, Apache doesn't use the requested 500 file
anymore - it throws the Apache default instead.

THIS IS A HUGE PROBLEM because I obviously won't let my customers modify
the httpd.conf file (yikes)!  I do however, allow them to use .htaccess
files.

Here's the virtualhost section of httpd.conf (WORKS):
<VirtualHost 10.1.1.5>
...snip...
   ErrorDocument 500 /cgi-bin/nice500.cgi
   DocumentRoot /net/www/wfp86007/www
   ScriptAlias /cgi-bin/ /utils/cgi-bin/
   AddHandler cgi-wrapper .cgi .pl
   Action cgi-wrapper /cgi-bin/cgiwrap/~wfp86007
</VirtualHost>

.htaccess in /net/www/wfp86007 (500 WON'T WORK, 404 WORKS):
ErrorDocument 500 /cgi-bin/nice500.cgi
ErrorDocument 404 /404.htm

To answer Joshua's questions: 
> are you editting the right config file?

I only have one httpd.conf on the system & the one .htaccess file is
redirecting 404s, so yes I believe I'm using the right .htaccess file.

> Are you placing the directive in the right part of the config file?

There is no right place to put directives in .htaccess as far as I can
tell.  

> Are you restarting after making changes?

And yes, I restart Apache when I change the httpd.conf, but you
shouldn't have to after uploading a new .htaccess.  Even so, I tried
restarting Apache after updating the .htaccess and that didn't change
anything.

Has ANYBODY successfully used Apache 1.3.22, CGIWrap, and .htaccess
together???

-Kyle

Joshua Slive wrote:
> Sorry, but it works fine for me.  All I can suggest is the obvious: are
> you editting the right config file?  Are you placing the directive in
> the right part of the config file?  Are you restarting after making changes?
> 
> Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Joshua Slive <jo...@slive.ca>.
Kyle wrote:
> I hate to be pushy but this is a bad problem for me.  Nobody in the
> group can give me any pointers on why Apache is throwing the wrong error
> page for 500s?
> 

Sorry, but it works fine for me.  All I can suggest is the obvious: are 
you editting the right config file?  Are you placing the directive in 
the right part of the config file?  Are you restarting after making changes?

Joshua.



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Kyle <ky...@ccidomain.com>.
I hate to be pushy but this is a bad problem for me.  Nobody in the
group can give me any pointers on why Apache is throwing the wrong error
page for 500s?

(original posting at bottom)

-Kyle

Kyle wrote:
> 
> I just created a 500 on purpose, got the wrong 500 page, and this is
> what showed up in the error log:
> [Thu Apr 11 14:24:39 2002] [error] [client 10.1.1.202] malformed header
> from script. Bad header=Scalar found where operator ex:
> /utils/cgi-bin/cgiwrap
> 
> Keep in mind that I'm not asking the group for help fixing the 500 - I'm
> just trying to get the right 500 page for clients to see if (when) they
> happen.  :)
> 
> -Kyle
> 
> Joshua Slive wrote:
> >
> > On Thu, 11 Apr 2002, Kyle wrote:
> >
> > > I only use MSIE when forced to do so.  I usually use Netscape 4.79.  But
> > > I don't think this problem is browser dependent since I'm seeing an
> > > APACHE error message instead of the one I'm redirecting to.
> >
> > OK.  I just had to check the obvious.
> >
> > What does the error log say in this case?
> >
> > Joshua.


I have a site that uses a simple .htaccess file for error document
redirects.  The redirect for 404 errors works, but the one for 500
errors does not.  The server is 1.3.22 and RH7.1.  Here is the entire
.htaccess file:

errordocument 404 /404.htm
errordocument 500 /500.htm

The 404 one works by overriding the default 404 document called out in
the httpd.conf as expected.  But for 500s, you get the default page that
is called out in httpd.conf instead of .htaccess.  Both 404.htm and
500.htm files exist in the same directory with the same owner, same
group, and same permissions (644).

The way my virtual hosts are set up, each virtual host equates to a user
home directory.  If you go to that user's directory, you'll see the
following dirs:
www
cgi-bin

www is the "root" for web domains and I have the following line to use
CGIWrap and make it appear that the cgi-bin is in the user's web area:
   Action cgi-wrapper /cgi-bin/cgiwrap/~www08591

I have copied the .htaccess to the user's home dir, the www dir, and the
cgi-bin dir, and in all cases, the 404.htm gets called, but the 500.htm
does not.

If the Apache site has any help on this, I haven't been able to find
it.  Can anybody offer any hints?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Kyle <ky...@ccidomain.com>.
I just created a 500 on purpose, got the wrong 500 page, and this is
what showed up in the error log:
[Thu Apr 11 14:24:39 2002] [error] [client 10.1.1.202] malformed header
from script. Bad header=Scalar found where operator ex:
/utils/cgi-bin/cgiwrap

Keep in mind that I'm not asking the group for help fixing the 500 - I'm
just trying to get the right 500 page for clients to see if (when) they
happen.  :)

-Kyle

Joshua Slive wrote:
> 
> On Thu, 11 Apr 2002, Kyle wrote:
> 
> > I only use MSIE when forced to do so.  I usually use Netscape 4.79.  But
> > I don't think this problem is browser dependent since I'm seeing an
> > APACHE error message instead of the one I'm redirecting to.
> 
> OK.  I just had to check the obvious.
> 
> What does the error log say in this case?
> 
> Joshua.
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Joshua Slive <jo...@slive.ca>.
On Thu, 11 Apr 2002, Kyle wrote:

> I only use MSIE when forced to do so.  I usually use Netscape 4.79.  But
> I don't think this problem is browser dependent since I'm seeing an
> APACHE error message instead of the one I'm redirecting to.

OK.  I just had to check the obvious.

What does the error log say in this case?

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Kyle <ky...@ccidomain.com>.
I only use MSIE when forced to do so.  I usually use Netscape 4.79.  But
I don't think this problem is browser dependent since I'm seeing an
APACHE error message instead of the one I'm redirecting to.

"Internal Server Error

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

Please contact..."

-Kyle



Joshua Slive wrote:
> 
> On Thu, 11 Apr 2002, Kyle wrote:
> 
> > I have a site that uses a simple .htaccess file for error document
> > redirects.  The redirect for 404 errors works, but the one for 500
> > errors does not.  The server is 1.3.22 and RH7.1.  Here is the entire
> > .htaccess file:
> 
> Have you tried this with a browser OTHER THAN MSIE?  MSIE ignores
> server-supplied error pages if they are "too small".
> 
> Joshua.
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: .htaccess - 404 works, 500 doesn't

Posted by Joshua Slive <jo...@slive.ca>.
On Thu, 11 Apr 2002, Kyle wrote:

> I have a site that uses a simple .htaccess file for error document
> redirects.  The redirect for 404 errors works, but the one for 500
> errors does not.  The server is 1.3.22 and RH7.1.  Here is the entire
> .htaccess file:

Have you tried this with a browser OTHER THAN MSIE?  MSIE ignores
server-supplied error pages if they are "too small".

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org