Difference between revisions of "Apache 2 - Custom error page"

(Created page with "Edit your virtual host configuration: vim /etc/apache2/site-enabled/smartcards.conf Add: ## ERROR directory Alias /errors /var/www/errors <Locatio...")
 
Line 1: Line 1:
 +
[[Category:Linux]]
 +
 +
=Update Apache2=
 +
 
Edit your virtual host configuration:
 
Edit your virtual host configuration:
 +
 +
<syntaxhighlight lang="bash">
 
vim /etc/apache2/site-enabled/smartcards.conf
 
vim /etc/apache2/site-enabled/smartcards.conf
 +
</syntaxhighlight>
 +
  
 
Add:
 
Add:
 +
 +
<syntaxhighlight lang="bash">
 
         ## ERROR directory
 
         ## ERROR directory
 
         Alias  /errors  /var/www/errors
 
         Alias  /errors  /var/www/errors
Line 13: Line 23:
  
 
         ErrorDocument 403 /errors/error403.html
 
         ErrorDocument 403 /errors/error403.html
 +
</syntaxhighlight>
  
Create the error page
+
 
 +
 
 +
=Create the error page=
 +
 
 +
 
 +
<syntaxhighlight lang="bash">
 
mkdir -p /var/www/errors
 
mkdir -p /var/www/errors
 
cp <monImage> /var/www/errors/error403.png
 
cp <monImage> /var/www/errors/error403.png
 
vim /var/www/errors/error403.html
 
vim /var/www/errors/error403.html
 +
</syntaxhighlight>
 +
 +
 +
Put the following content
 +
 +
<syntaxhighlight lang="html">
 +
<html>
 +
<head>
 +
<title>403 - Forbidden</title>
 +
<style type="text/css">
 +
.content {
 +
width:880px;
 +
margin: 0 auto;
 +
}
 +
.wrapper {
 +
display:block;
 +
overflow: auto;
 +
}
 +
.errorText {
 +
color: #D63301;
 +
//background-color: #FFCCBA;
 +
font-size: 1.25em;
 +
}
 +
</style>
 +
 +
 +
</head>
 +
 +
<body>
 +
<div class="wrapper">
 +
<div class="content">
 +
<img src="./Error_403.png" alt="Error 403" />
 +
</div>
 +
</div>
 +
</body>
 +
</html>
 +
</syntaxhighlight>
 +
 +
 +
 +
You can download the image over here:
 +
 +
 +
 +
 +
Set rights
 +
 +
<syntaxhighlight lang="bash">
 +
chown -R www-data:www-data /var/www/errors
 +
chmod -R 755 /var/www/errors
 +
</syntaxhighlight>

Revision as of 23:11, 31 July 2014


Update Apache2

Edit your virtual host configuration:

vim /etc/apache2/site-enabled/smartcards.conf


Add:

        ## ERROR directory
        Alias   /errors   /var/www/errors
        <Location /errors >
                #Require all granted
                ProxyPass !
                order deny,allow
                allow from all
        </Location>

        ErrorDocument 403 /errors/error403.html


Create the error page

mkdir -p /var/www/errors
cp <monImage> /var/www/errors/error403.png
vim /var/www/errors/error403.html


Put the following content

<html>
	<head>
		<title>403 - Forbidden</title>
		<style type="text/css">		
			.content { 
				width:880px;
				margin: 0 auto;
			}
			.wrapper { 
				display:block; 
				overflow: auto;
			}
			.errorText {
				color: #D63301;
				//background-color: #FFCCBA;
				font-size: 1.25em;
			}
		</style>

		
	</head>

	<body>
		<div class="wrapper">
			<div class="content">
				<img src="./Error_403.png" alt="Error 403" />
			</div>
		</div>
	</body>
</html>


You can download the image over here:



Set rights

chown -R www-data:www-data /var/www/errors
chmod -R 755 /var/www/errors