As Lumpy already alluded to, within the web site folder where phpBB is installed, it is not expected that you will get "the web server's default or custom 404 page." If the phpBB required configuration is used, any URL which
would have resulted in a 404 from the web server is instead being passed to phpBB's app.php module. To give phpBB and/or installed extensions the chance to claim that path and provide content.
For example, there is no mysite.com/chat folder on my site, and if the web server was all that was setup (without phpBB), this would result in a 404 page. But because phpBB is installed, the web server is configured to process this otherwise-404 URL as mysite.com/app.php/chat. And my installed chat extension is what comes up in response to users trying to invoke the mysite.com/chat URL, even though "that folder doesn't exist."
So if you were expecting there was just a different static page you needed to create, e.g. 404.html, its not going to be that easy. The extension that David linked to is definitely on point, although not entirely clear where the current and future compatibility will stand.
Although it's possible to customize the style's template that phpBB uses for this message (
/styles/prosilver/template/message_body.html), that same template is used for lots of other types of messages. So if you unconditionally add an image to that template, it will show up in
every type of message, and not just
"The requested page could not be found."
To further complicate a style-based solution, the templating
<-- IF -->
conditions cannot be used against the language variables, which prevents you from making some kind of simple template decision such as
<-- IF MESSAGE_TEXT == L_PAGE_NOT_FOUND -->
for adding your conditional image in a language-agnostic manner. Involving some simple Javascript almost gets you there, but will be brittle when
MESSAGE_TEXT
happens to contain some complex message which contains characters that will be interpreted as part of the Javascript parsing.
Rather than going further down that path, perhaps the easiest non-extension and non-style approach would be to edit your installed phpBB language(s), so that the definition of PAGE_NOT_FOUND in
/language/<language>/common.php contains the additional image reference. For example in the default English language pack:
Code: Select all
'PAGE_NOT_FOUND' => 'The requested page could not be found.<br><img src="images/inappropriate-time-four-oh-for-ham.gif">',
You could of course add additional direct CSS styling or classing in order to further control how exactly the image displays. Just keep in mind that phpBB is already displaying this message inside of a
<p></p>
paragraph element.
This of course does mean your change would have to be re-implemented after every phpBB update, and/or any time you updated a language pack which overwrites the common.php change you made. But since this is a purely cosmetic change anyway, and nothing will be "broken" until you re-implement, that doesn't seem like the worst story.
If you're already maintaining a customized style for your site and would like to pursue the style-based approach instead, let us know and I'm sure we can come up with a way to make the Javascript solution non-brittle. The route I would pursue is to put the messages into hidden DOM elements, and then use Javascript to compare their .innerHtml or similar, instead of treating the messages as literal strings. But someone else might have an even smarter style- or template-based solution.