How To Institute Custom 404 Not Found Web Page

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How To Institute Custom 404 Not Found Web Page

Postby steve_t » 07. October 2015 23:30

How To Institute A Custom 404 Not Found Web Page On XAMPP Apache Web Server

The following works for me. If there is a better way, please reply.

Steve

==================================================
==================================================

HOW TO INSTITUTE A CUSTOM 404 NOT FOUND WEB PAGE ON XAMPP APACHE WEB SERVER
METHOD 1: VIA EDITING THE C:\xampp\apache\conf\httpd.conf FILE

1.) Edit The C:\xampp\apache\conf\httpd.conf File
--------------------------------------------------------------
a.) Open the C:\xampp\apache\conf\httpd.conf file.
b.) Go to the <Directory "C:/xampp/htdocs"></Directory> section.
c.) Add the following line just before the closing </Directory>:

ErrorDocument 404 /missing.html

In other words, change:

#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>

To:

#
# Controls who can get stuff from this server.
#
Require all granted
ErrorDocument 404 /missing.html
</Directory>

Note: In this example, the custom 404 not found web page is named missing.html. The custom 404 not found web page does not need to be named missing.html. For example, the custom 404 not found web page could be named 404_not_found.html, 404.html, or whatever makes sense to you.

c.) Save the C:\xampp\apache\conf\httpd.conf file.
d.) If the XAMPP Apache web server is started, stop and start it.

2.) Create The Custom 404 Not Found Web Page missing.html And Copy It To The Root Of The XAMPP Apache Web Server
----------------------------------------------------------------------------------------------------------------
a.) Create the custom 404 not found web page missing.html and copy it to the root of the XAMPP Apache Web Server, which is typically C:\xampp\htdocs\.

Note: If you are using virtual hosts, instead of copying the missing.html file to root of the XAMPP Apache web server, you can copy the missing.html file to the root of the virtual host as specified by the DocumentRoot directive in the C:\xampp\apache\conf\extra\httpd-vhosts.conf file.
Note: To avoid Internet Explorer using its own error message instead of your custom 404 not found web page, make your custom 404 not found web page greater than 512 bytes. For more on this see:
Apache Core Features: ErrorDocument Directive
http://httpd.apache.org/docs/2.4/mod/core.html#errordocument
How to turn off the Internet Explorer "Show Friendly HTTP Error Messages" feature on the server side
https://support.microsoft.com/en-us/kb/294807

==================================================
==================================================

HOW TO INSTITUTE A CUSTOM 404 NOT FOUND WEB PAGE ON XAMPP APACHE WEB SERVER
METHOD 2: VIA CREATING AN .htaccess FILE

1.) Create An .htaccess File
----------------------------
a.) Open notepad.
b.) Click File | Save As. The Save As dialog appears.
c.) In the File name field, enter ".htaccess"

Note: Yes, include the quotes. The quotes indicate to explicitly/literally use the enclosed file name and nothing else.

d.) Click Save.

2.) Copy The .htacces File To The Root Of The XAMPP Apache Web Server
---------------------------------------------------------------------
a.) Copy the .htaccess file to the root of the XAMPP Apache web server, which is typically C:\xampp\htdocs\.

Note: If you are using virtual hosts, instead of copying the .htaccess file to root of the XAMPP Apache web server, you can copy the .htaccess file to the root of the virtual host as specified by the DocumentRoot directive in the C:\xampp\apache\conf\extra\httpd-vhosts.conf file.

3.) Specify The Custom 404 Not Found Web Page In The .htaccess File
-------------------------------------------------------------------
a.) Add the following line to the .htaccess file:

ErrorDocument 404 /missing.html

Note: In this example, the custom 404 not found web page is named missing.html. The custom 404 not found web page does not need to be named missing.html. For example, the custom 404 not found web page could be named 404_not_found.html, 404.html, or whatever makes sense to you.
Note: /missing.html is a root relative path.

4.) Create The Custom 404 Not Found Web Page missing.html And Copy It To The Root Of The XAMPP Apache Web Server
----------------------------------------------------------------------------------------------------------------
a.) Create the custom 404 not found web page missing.html and copy it to the root of the XAMPP Apache Web Server, which is typically C:\xampp\htdocs\.

Note: If you are using virtual hosts, instead of copying the missing.html file to root of the XAMPP Apache web server, you can copy the missing.html file to the root of the virtual host as specified by the DocumentRoot directive in the C:\xampp\apache\conf\extra\httpd-vhosts.conf file.
Note: To avoid Internet Explorer using its own error message instead of your custom 404 not found web page, make your custom 404 not found web page greater than 512 bytes. For more on this see:
Apache Core Features: ErrorDocument Directive
http://httpd.apache.org/docs/2.4/mod/core.html#errordocument
How to turn off the Internet Explorer "Show Friendly HTTP Error Messages" feature on the server side
https://support.microsoft.com/en-us/kb/294807
steve_t
 
Posts: 15
Joined: 18. December 2014 04:28
XAMPP version: 5.6.24
Operating System: Windows Vista/7/8.1/10

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 119 guests