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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Configuring error page redirect 1

Status
Not open for further replies.

gringomike

Technical User
Aug 6, 2003
148
GB
Hi all,

Really wondering if anyone has done it, please give me pointers regarding how to implement it. Tons of document suggest how to use custome error pages with IHS/Apache. Trying to implement simplest custom error page for http error 404. As per the docs, I need to add a line ErrorDocument 404 /error404.html where error404.html should be in docroot folder. After this modification, I never forget to restart IHS. Still if I give any invalid url (i.e. when test.html does not exist at server), I see the usual http 404 page, not the error page error404.html which I would like. Is here something I am missing???

Thanks in advance

GM
 
gringomike,

What you describe above sounds correct.

Add the line
ErrorDocument 404 /filename.html
and restart Apache.

In my httpd.conf, I have the line
ErrorDocument 404 /404.php.

What do your Apache logs show?

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
We don't appear to have anything in our logs.

I'll work out why it's not logging anything then take a look at what they say once they are generated.

Thanks for the time being....

GM
 
gringomike,

Just off the top of my head, both could be caused by permission errors.

One it starts logging, at least you'll know what the errors are.

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
Hi Wishdiak,

It turns out IHS was logging to a different place. Below is an extract from the log file which (I think) shows that the requested page cannot be found thus resulting in a 404 error.

I have this line in my httpd.conf file;

ErrorDocument 404 /usr/IBMIHS/error/new_404_error.htm



1.36.100.60 testps10 - - [08/Jul/2005:16:07:56 +0100] "GET /favicon.ico HTTP/1.1
" 404 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.7.5) Gecko/200
41110 Firefox/1.0"
1.36.100.60 testps10 - - [08/Jul/2005:16:08:00 +0100] "GET /favicon.ico HTTP/1.1
" 404 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.7.5) Gecko/200
41110 Firefox/1.0"
1.36.100.60 testps10 - - [08/Jul/2005:16:08:01 +0100] "GET /mike/test.html HTTP/
1.1" 404 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.7.5) Gecko/
20041110 Firefox/1.0"
1.36.100.60 testps10 - - [08/Jul/2005:16:08:01 +0100] "GET /favicon.ico HTTP/1.1
" 404 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.7.5) Gecko/200
41110 Firefox/1.0"


Also, I have virtualhosts configured in my httpd.conf. I've added the ErrorDocument line into these to make sure this wasn't causing me any problems but this hasn't made any difference either.

Any ideas?

Thanks for your help!

GM
 
gringomike,

I think I see the problem.

First of all, you only need to define the ErrorDocument directive once unless you want to specify different handlers for different VirtualHosts.

Second, the path in the ErrorDocument, like most directives in Apache, is relative to the DocumentRoot directive.

If your DocumentRoot is /some/path, and the full path to your error document is /some/path/to/file, then you should have:
ErrorDocument /to/file which will be appended to /some/path.

You have your ErrorDocument directive specified as the full path within your filesystem which is getting appended to the DocumentRoot, and thus is not found.

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
Great - thanks Wishdiak!

I had a feeling I was doing something silly!

GM
 
Pretty much - I still have an issue as WebSphere is over-riding the httpd.conf specifications for certain URL's but I'm working on getting that sorted at the moment. It's a code problem rather than a Web Server one.

Thanks again for your help!
 
Can you help me with the (almost) same problem??

I read all the previews messages but it didn’t work here. I have Apache in a Win2000 server. In fact, the server is my desktop.

I hope you understand my ad English and I are thanked for your attention. (Is this sentence correct? MS Word is helping me, but I am not sure if it is helpful).

I have two problems.

First.

When I put:
ErrorDocument 404 "C:/erro.php"
In httpd.conf it works.

But if I try to redirect to my DocumentRoot, it didn’t work.

I tried:
ErrorDocument 404 erro.php
or
ErrorDocument 404 /erro.php

I also tried the full path to my DocumentRoot.

ErrorDocument 404 "C:/Documents and Settings/Meus documentos/Pessoal/htdocs/erro.php"



Second.

Even when Apache find the file, PHP don’t work, just don’t translated the PHP to HTML. PHP is ok, in other PHP files it works fine. But in this file, nothing happened. All PHP codes were sendo to the browser.


Any ideas?
 
RLyra,

For both of these problems, you should look at your Apache logs. There is plenty of documentation on installing Apache on Windows, but not so much about ordinary configuration and operation.

I suspect that for the first problem, you may be specifying the path incorrectly.

For the second problem, I supsect that you either have a typo in your opening or closing php tags, a different file extension (like error.php.txt) or the directory that contains it is somehow exempt from parsing php code.

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
Believe or not.

In the first problem, my problem was this (“).

In DocumentRoot I write the path with “, because the path have spaces. I thought that I had to do the same in ErrorDocument, but no.

When I just wrote the same path without (“), it’s works.

Look the two lines:
DocumentRoot "C:/Documents and Settings/Meus documentos/Pessoal/PenDrive/htdocs"
And
ErrorDocument 404 C:/Documents and Settings/Meus documentos/Pessoal/PenDrive/htdocs/erro.php

Why it’s different? I don’t know.

About the second, I have no idea yet. Maybe is a exception in ErrorDocument.

I still looking for it.
 
I found 1 thing.

ErrorDocument aceppt a text as a argument. That why you can't use ("). If it has ", this is a text, not a path to a file.
 
RLyra,

That makes sense, since ErrorDocument does accept a string of text as an argument, whereas DocumentRoot does not.

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top