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$
</If>
</Files>
<Files "50x.html">
<If "-z %{ENV:REDIRECT_STATUS}">
RedirectMatch 404 ^/50x.html$
</If>
</Files>
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.
^/404.html$
would not seem to match, since your error document appears to be located at/error_pages/404.html
? – MrWhite Nov 14 '16 at 19:25Not 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 Nov 14 '16 at 21:09