Jump to content
Larry Ullman's Book Forums

Create A 404 Error Page.


Recommended Posts

I'm using Zend Server CE and I'm trying to create my own 404 error page to show when the requested page does not exist.

 

I have asked for help on Zend's board but there doesn't seem to be many reading those boards. I have also looked up information on editing the httpd.conf and other Apache files, as well as numerous tutorials that don't seem to help since I'm using Zend Server.

 

I can locate my httpd.conf, magic, and zend.conf files, however I don't know where exactly to add this:

ErrorDocument 404 /htdocs/site im working on/404.php

 

I don't know if Zend Server has another layer of abstraction that is making this more difficult or what, but if someone has experience creating a 404 page, especially on Zend Server Community edition, please let me know exactly what to do.

Link to comment
Share on other sites

I have not used Zend Server CE, so I can't give you a specific answer. But one option would be to place that within a Directory block in an httpd.conf file. Or you could put it within a .htacess file within the applicable directory, assuming the server is set to allow for directory overrides.

Link to comment
Share on other sites

There is only one httpd.conf file, can I just start a new directory tag and put the ErrorDocument directive in there? I tried to make an htaccess file once, but it didn't seem as if it was taking effect at all even after restarting the server.

 

Here is part of the httpd.conf file, I understand what it's telling me to do, but it's not clear as to "where" I should put the ErrorDocument tag.

#
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /path to file
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#
#

 

Where do I put the ErrorDocument directive with my path?

Link to comment
Share on other sites

I tried removing the hash and pointing to my 404 file but it never shows up. When I go to a page in my project that doesn't exist, it shows me a generic 'this file doesn't exist on the server' text message on a white page.

Link to comment
Share on other sites

For Larry and anyone else having this problem using Zend Server, I figured it out.

 

I tried the .htaccess method, creating a simple file within my site root, htdocs:

ErrorDocument 404 /my_site/404.php

 

It still didn't work, but I searched and found a post by someone whose htaccess file didn't have any effect. A followup post mentioned to make sure the fileinfo overide in the httpd.conf file was set to "All" and not none. I fixed this and it still didn't work. Then someone mentioned (duh) to restart Apache. I thought I was restarting Apache each time. Whenever I would make a change, I would hit the "restart PHP" button in the Zend Server GUI. However, "restart PHP" is not restarting the server (stupid, stupid on my part). So in my taskbar I just chose the icon for Apache services and hit restart. After it restarted I went to a nonexistant page and it worked, my own 404 error page.

 

Thanks for the help and suggestions.

Link to comment
Share on other sites

A quick followup --

Larry, you were right I could also just put my 404 page in the httpd.conf file where it mentioned ErrorDocument, not even needing an htaccess file.

 

That "restart php" button had me stumped for weeks. I think 99% of people will think it restarts Apache.

Link to comment
Share on other sites

 Share

×
×
  • Create New...