In this tutorial you will learn how to custom error pages in Apache on Ubuntu Server.
Code used during this tutorial:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# Apache Custom error pages on Ubuntu Server # Create Apache custom errors dir mkdir /var/www/http.liviubalan.com/apache-errors # Create Apache 404 error HTML vi /var/www/http.liviubalan.com/apache-errors/404.html <h1 style="color: #f00;">Error 404: Not found :-(</h1> <p>I have no idea where that file is, sorry. Are you sure you typed in the correct URL?</p> # Create Apache 50x error HTML vi /var/www/http.liviubalan.com/apache-errors/50x.html <h1 style="color: #0f0;">Oops! Something went wrong...</h1> <p>We seem to be having some technical difficulties. Hang tight.</p> sudo vi /etc/apache2/sites-available/http.liviubalan.com.conf <Directory "/var/www/wp.liviubalan.com/"> <Files "file.txt"> AuthType Basic AuthName "Restricted Content" AuthUserFile /etc/apache2/.htpasswd Require valid-user </Files> # What the server will return to the client in case of an error ErrorDocument 404 /apache-errors/404.html ErrorDocument 500 /apache-errors/50x.html ErrorDocument 502 /apache-errors/50x.html ErrorDocument 503 /apache-errors/50x.html ErrorDocument 504 /apache-errors/50x.html </Directory> # Restart Apache sudo service apache2 restart # Browser http://http.liviubalan.com/page-not-found http://http.liviubalan.com/protected-files/file.txt # Useful links https://www.digitalocean.com/community/tutorials/how-to-configure-apache-to-use-custom-error-pages-on-ubuntu-14-04 https://httpd.apache.org/docs/2.4/mod/core.html#errordocument |
Useful links:
https://www.digitalocean.com/community/tutorials/how-to-configure-apache-to-use-custom-error-pages-on-ubuntu-14-04
https://httpd.apache.org/docs/2.4/mod/core.html#errordocument