Apache Custom error message 403
i wanna to create a custom error message in Apache conf for the Error message 403 Forbidden You don't have permission to access / on this server to appear like 404 Not Found The requested URL / was not found on this server.
Is this possible to do with Apache? Thanks in advance, any help is appreciated.
2 Answers
In ubuntu
nano /etc/apache2/apache2.confedit the AllowOverride feature to ALL
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>You need access to .htaccess.
ErrorDocument 500 "Sorry you are late Session Time out!!!"
ErrorDocument 403 /xyz/yxz/error.html 1 Take a look at the Apache HTTP Server Tutorial: .htaccess files
From the htaccess site:
.htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory which is in turn 'loaded via the Apache Web Server', then the .htaccess file is detected and executed by the Apache Web Server software. These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. These facilities include basic redirect functionality, for instance if a 404 file not found error occurs, or for more advanced functions such as content password protection or image hot link prevention.
To set-up custom error documents, create a .htaccess:
echo "ErrorDocument 404 /error_pages/404.html" > .htaccessThe above line tells the Apache Web Server to display the document located at /error_pages/404.html (under your domain name/web site address) whenever a 404 (file not found) error occurs.
It is assumed you have created the error document and called it 404.html and that you have placed it in a directory called error_pages under your domain name. For example,
The document 404.html is a normal HTML document like the others in your web site and can display whatever content you wish, however it is useful to include a 'File Not Found' message.
To setup further error documents, for example for '401 Unauthorised', '403 Forbidden', and '500 Internal Server' error messages, create a .htaccess file following the main instructions and guidance which includes the following text:
ErrorDocument 401 /error_pages/401.html
ErrorDocument 404 /error_pages/404.html
ErrorDocument 500 /error_pages/500.html 5