Htaccess: Site error documents: Difference between revisions

Jump to navigation Jump to search
Moved to new category; Additional grammar and cleanup edits.
No edit summary
(Moved to new category; Additional grammar and cleanup edits.)
Line 2: Line 2:
<div style="padding:0;margin:0; border-bottom:3px inset #000000">
<div style="padding:0;margin:0; border-bottom:3px inset #000000">
{|  
{|  
|[[Image:uc_small_logo.gif | MPG UniCenter]] ||
 
.htaccess:  
.htaccess:  
[[Htaccess: Introduction | Introduction]] |   
[[Htaccess: Introduction | Introduction]] |   
Line 63: Line 63:


== How to create customised error documents ==
== How to create customised error documents ==
Create a new folder in your root folder (www) and name it '''errors'''. This folder contains all the error pages you wish to display. For example, '''not_found.html''' will be displayed when a page cannot be found on your web site.
Create a new folder in your root folder (www) and name it '''errors'''. This folder will contain all the custom error pages you wish to display. For example, '''not_found.html''' will be displayed when a page cannot be found on your web site.


Now open the root .htaccess file (the one in your root folder www) and add the following line:
Now open the root .htaccess file (the one in your root folder www) and add the following line:
Line 69: Line 69:
'''ErrorDocument 404 /errors/not_found.html'''
'''ErrorDocument 404 /errors/not_found.html'''


Save the file. The command '''ErrorDocument 404''' will forward a user to '''<root folder>/errors/not_found.html''' file when ever Apache produces the error 404.
Save the file. The command '''ErrorDocument 404''' will forward a user to the '''<root folder>/errors/not_found.html''' file when ever Apache produces the error 404.


'''''Note 1'':''' The files and folder can be named anything you like.<br>
'''''Note 1'':''' The files and folder can be named anything you like.<br>
Line 125: Line 125:
|
|
<pre style="padding:4px;margin:0;border:none">
<pre style="padding:4px;margin:0;border:none">
# This file provides security to the server limiting access to the localhost only.
# This file provides security for the server, limiting access to the localhost only.
# Comment to deactivate.
# Comment to deactivate.


Line 133: Line 133:
Allow from ::1
Allow from ::1


# To allow execution of cgi scripts in this directory, uncomment next two lines.&nbsp;
# To allow execution of cgi scripts in this directory, uncomment the next two lines.&nbsp;


AddHandler cgi-script .pl .cgi
AddHandler cgi-script .pl .cgi
Line 152: Line 152:
=== Testing ===
=== Testing ===


:# Run the server using Start.exe
:# (Re)start the server.
:# In the browser address bar, type '''<nowiki>http:/localhost/fred.html</nowiki>''' or some other file that does not exist.
:# In the browser address bar, type '''<nowiki>http:/localhost/fred.html</nowiki>''' or some other file that does not exist.
:# Apache will generate the error code 404 and redirect to your not_found.html page
:# Apache will generate the error code 404 and redirect to your not_found.html page


Experiment with the ErrorDocument command and create a few pages.
Experiment with the ErrorDocument command and create a few other pages.
   
   


----
----


[[Category: Support]]
[[Category: Apache Configuration]]
[[Category: Troubleshooting ]]
[[Category: Development]]

Navigation menu