LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache custom error pages not working (https://www.linuxquestions.org/questions/linux-server-73/apache-custom-error-pages-not-working-4175469191/)

baronobeefdip 07-10-2013 03:31 PM

Apache custom error pages not working
 
I have a virtualhost setup and I wanted to make custom error pages for it and only it. I don't want the entire apache server host collection to display these types of error pages. I have my virtualhost setup like this
Code:

<IFModule mod_log_config>
<VirtualHost *:80>
ErrorDocument 404 /crash.html
ServerName joomla.baronobeefdip.josh
DocumentRoot /var/www/html
LogFormat "%v %h %l %u %t \"%r\" %>s %b" joomla.baronobeefdip
CustomLog logs/joomla.baronobeefdip joomla.baronobeefdip
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
</IFModule>

The error document exists in the top level directory in the apache virtual host. I also made sure that I did a chown command on it like so.
Code:

chown apache:apache crash.html
I restarted the apache service and browsed to a page that didn't exist on the server (and tried to access a file that I deleted to get the "not found" error page). When the error page appeared it was the page that apache displays by default. I need help trying to get the custom error pages to work as simple as possible.

Linux MR 07-11-2013 12:15 AM

I ran into a similar problem recently. It may help to view the log file for apache (mine was /var/log/httpd/{access.log,error.log}).

My issue was that apache was looking for my file starting at the DocumentRoot.
So in my httpd.conf file my DocumentRoot was /var/www/html but I wanted it to look at /var/www/testDir/sample.html

The error log said /var/www/html/testDir/sample.html doesn't exist! I resolved my issue by putting a symbolic/soft link in the /var/www/html to the testDir

Hope that can get you started....or help somehow

zhjim 07-11-2013 02:03 AM

As Linux MR pointed out the ErrorDocument directive if it starts with a / is in relation to the DocumentRoot directive. In your case the file /var/www/html/crash.html would be called on a 404.

How did you restart the apache? I sometime experienced that apache2ctl -k restart does not take all changes in effect. Mostly with rewrite rules. I have to stop and then restart the service.


All times are GMT -5. The time now is 01:00 AM.