The BU Web has a custom error page for all of www.bu.edu. However, you can implement your own custom error page within your site on www.bu.edu.

A custom error page is simply an HTML file named 404.html placed inside an error folder on the web server. When a visitor requests page that doesn’t exist, the server will look for an error folder on the same level as that page and display the custom error page. If there is no error folder on that level, the server will continue to look one level up, and so on, until it finds the error folder for the entire www.bu.edu domain and displays the error page for BU. This not only allows you to make a custom error page sitewide, by putting your error folder on the top level of your site, but also allows you to implement a specific error page for a section within your site.

Sitewide

implement1

Follow these instructions to create your very own custom error page that visitors will see if they encounter an error anywhere on your site.

  1. Create a new folder at your top level directory named error.
  2. Within the error folder, create a file named 404.html using your site template, so that it has the look and feel of your site.
  3. Open the 404.html file and insert an error message and the specific content you wish to incorporate in your custom error pages.This includes the following:
    • Display URL: Including a snippet of code to your page will display the URL they initially requested. This can help visitors backtrack. Examples: TechWeb and BU Alumni Web. Include a message like, “The page requested below does not exist or is currently unavailable” and on the next line type:
      $ENV{REDIRECT_URL}

      When a visitor views the page, the error page will display the URL of the page he or she attempted to find immediately below the error message.
    • Custom Searches: Incorporating a search box helps your visitors locate the page they were intending to see. Example: TechWeb.
    • Listing of Site Changes: If your site has recently undergone major changes, providing or linking to a list of changes in your site can help visitors find the correct location of the page they were trying to locate and help administrators of other sites fix broken links they may have to content on your site.
  4. Save the file.
  5. Upload the error folder to the server.
  6. Test your site see if the file is displayed by browsing to a file within your site that doesn’t exist.

For example, if the URL of your site is http://www.bu.edu/hcep/, you can type in a filename after the slash which is not there, such as http://www.bu.edu/hcep/brokenpage, to see the error message page that you just created.

Specific Folder

As mentioned, you can also create a custom error page for a specific folder within your site. This is useful for providing an alternate error message following a change in site structure, where an entire section of the site has been moved to a new location.

implement2

This is done in exactly the same way as implementing your custom error page sitewide, except instead of putting the error folder only in your top level directory, put an additional error folder in the folder of a section of your site.

Once you have done this, place a 404.html file in this error folder containing content relevant to this section of the site.

Only this section and its subdirectories will display this message; all other sections of the site will display the sitewide custom error page.