Jump to content



Photo

Create A 404 Error Page.


  • Please log in to reply
8 replies to this topic

#1 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 29 February 2012 - 1:14 PM

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.
  • 0

#2 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,704 posts
  • LocationState College, PA (USA)

Posted 29 February 2012 - 2:16 PM

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.
  • 0

#3 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 29 February 2012 - 2:28 PM

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?
  • 0

#4 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,704 posts
  • LocationState College, PA (USA)

Posted 29 February 2012 - 2:47 PM

Well, if your httpd.conf file has those lines in it (which are comments), that normally indicates you can do exactly that at exactly that spot in the file.
  • 0

#5 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 29 February 2012 - 2:52 PM

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.
  • 0

#6 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,704 posts
  • LocationState College, PA (USA)

Posted 29 February 2012 - 2:59 PM

Okay. Well, that's really my best guess. I've not touched Zend Server, so am really grasping at straws here. If you figure something out, please let us know!
  • 0

#7 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 1 March 2012 - 12:31 PM

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.
  • 0

#8 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,704 posts
  • LocationState College, PA (USA)

Posted 1 March 2012 - 2:48 PM

Ah, excellent. Kudos for figuring it out and thanks for sharing what you learned. Not sure what "restart PHP" would mean then, if not "restart Apache" but apparently...
  • 0

#9 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 3 March 2012 - 5:37 PM

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.
  • 0