Apache 2 - Custom error page

Update Apache2

Edit your virtual host configuration:

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


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

        # 403 access forbidden
        ErrorDocument 403 /errors/error_403.html
        # 404 page not found
        ErrorDocument 404 /errors/error_404.html
        # 500 internal error
        ErrorDocument 500 /errors/error_500.html

Restart web server

service apache2 restart

Create the error page

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

Put the following content

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


		<div class="wrapper">
			<div class="content">
				<img src="./error_403.png" alt="Error 403" />
                                <span class="errorText">This website is restricted</span><br/>

!! Don't forget to adjust the path in <img ... />

Set rights

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


You can download some images in the following archive: errors.zip

Or below:

403 access forbidden

Error 403

404 page not found

Error 404

500 internal error

Error 500