Htaccess: Site error documents: Difference between revisions

Jump to navigation Jump to search
m
Folder to Directory.
(Moved to new category; Additional grammar and cleanup edits.)
m (Folder to Directory.)
 
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 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.
Create a new Directory in your root directory (www) and name it '''errors'''. This 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 directory www) and add the following line:


'''ErrorDocument 404 /errors/not_found.html'''
'''ErrorDocument 404 /errors/not_found.html'''


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.
Save the file. The command '''ErrorDocument 404''' will forward a user to the '''<root>/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 directory can be named anything you like.<br>
'''''Note 2'':''' You can use a full URL (as oppose to a virtual path) to your error file; for example: <nowiki>http://yoursite.com/errors/not_found.html</nowiki>
'''''Note 2'':''' You can use a full URL (as oppose to a virtual path) to your error file; for example: <nowiki>http://yoursite.com/errors/not_found.html</nowiki>


Line 98: Line 98:
|-style="background:#f9f9f9"
|-style="background:#f9f9f9"
|
|
# Create a new folder in www named '''errors'''.
# Create a new directory in www named '''errors'''.
# In this folder create a file named '''not_found.html'''&nbsp;
# In this directory create a file named '''not_found.html'''&nbsp;
# Add the code shown on the right.
# Add the code shown on the right.
# Save the file.
# Save the file.
Line 119: Line 119:
|-style="background:#f9f9f9"
|-style="background:#f9f9f9"
|
|
# Navigate to the root folder '''www'''.  
# Navigate to the root directory '''www'''.  
# Open the '''.htaccess''' file.
# Open the '''.htaccess''' file.
# Add the command shown on the right last line.   
# Add the command shown on the right last line.   

Navigation menu