I've been trying to solve this problem, I have a virtual machine with the same setup as my production server. The ErrorDocument line in 000-default.conf works on my VM, however it doesn't work on my production server.

The two seemingly different points are a) The production server has a security certificate and b) the 000-default.conf on the production server has mod_rewrite enabled while it's not being used, it is a difference.

I've disabled mod_rewrite to see what would happen, which has changed nothing. All documents

I have the default folder set (/var/www/html) and the only changes I've made to the 000-default.conf are as followed:

ErrorDocument 404 /error_pages/404.html
ErrorDocument 500 /error_pages/50x.html
ErrorDocument 502 /error_pages/50x.html
ErrorDocument 503 /error_pages/50x.html
ErrorDocument 504 /error_pages/50x.html

<Files "404.html">
    <If "-z %{ENV:REDIRECT_STATUS}">
        RedirectMatch 404 ^/404.html$

<Files "50x.html">
    <If "-z %{ENV:REDIRECT_STATUS}">
        RedirectMatch 404 ^/50x.html$

mod rewrite portion:

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.website.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

I'm not sure if this would be a cause either, however, my certificate is only valid for the www, and not the bare URL.

Not sure where to go from here, the server displays the default apache error page.

  • What do you see instead of your 404 error document? That mod_rewrite portion is presumably in the VirtualHost for port 80? (Taken out of context that mod_rewrite portion is a bit meaningless.)
    – MrWhite
    Commented Nov 14, 2016 at 16:46
  • It shows the default error page (apache 404 error for example). Yep, port 80, I posted only what was changed from the default 000-default.conf.
    – Chris
    Commented Nov 14, 2016 at 18:45
  • "It shows the default error page" - and there is no additional note that states, "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."? What happens when you try to access the 404 error document directly - what status code is returned? Although the pattern ^/404.html$ would not seem to match, since your error document appears to be located at /error_pages/404.html?
    – MrWhite
    Commented Nov 14, 2016 at 19:25
  • I scrutinized the page further, and noticed it said this:
    – Chris
    Commented Nov 14, 2016 at 21:02
  • Not Found The requested URL /lkjlkj was not found on this server. Apache/2.4.18 (Ubuntu) Server at www.website.com Port 443 I forgot that since I'm using certificates that I'm not on port 80 for the production server, rather I'm on port 443. I modified the 000-default.conf virtual host to port 443, however there was no change after restarting the server. To answer what happens when I try to access the error pages, I can open them, even when modifying the 000-default.conf to /error_pages/xxx.html.
    – Chris
    Commented Nov 14, 2016 at 21:09

1 Answer 1


Thanks to w3dk's questions I was able to work through why my page re-directs weren't working.

I was using let's encrypt for my security certificate, and because of (or perhaps my lack of knowledge), it created a new .conf file with the lines to load the ssl certificates (000-default-le-ssl.conf) which took precedent over the original default.conf.

When I modified this new .conf file everything worked correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.