Custom 404 Page

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
bearsharktopus
Registered User
Posts: 11
Joined: Sat Nov 16, 2019 8:15 pm

Custom 404 Page

Post by bearsharktopus »

Hi, friends.

I'm trying to create a custom 404 page for my forum, but I'm a bit code illiterate and I'm unsure of what exactly to do, step-by-step. All the previous stuff for this is back in 2010-11, with 3.0.x, so I'm unsure if it would be applicable to my 3.2.8 phpBB server -- plus, as mentioned, I don't really know what I'm doing, haha.

All I need is a page that displays a 404 image that I have, and that's it. I know I have to muck about in .htaccess, but I don't know where to find that or if it exists on my server.

Any help would be appreciated. Thanks!
User avatar
janus_zonstraal
Registered User
Posts: 4637
Joined: Sat Aug 30, 2014 1:30 pm

Re: Custom 404 Page

Post by janus_zonstraal »

Did you use the search function here?
https://www.phpbb.com/search/?q=Custom+404+Page
Sorry! My English is bat ;) !!!
bearsharktopus
Registered User
Posts: 11
Joined: Sat Nov 16, 2019 8:15 pm

Re: Custom 404 Page

Post by bearsharktopus »

Yes, I have! The issue is that I'm a dumbass and don't know what I'm doing, and I need a baby's step by step on it -- plus, those tutorials are, as I said, for 3.0.x, so I'm wondering if anything has changed since then.
User avatar
Lumpy Burgertushie
Registered User
Posts: 67926
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Custom 404 Page

Post by Lumpy Burgertushie »

I still can not get those instructions to work and create a 404 error page for phpbb. phpbb has its own error page when the page can not be found.

robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?
User avatar
janus_zonstraal
Registered User
Posts: 4637
Joined: Sat Aug 30, 2014 1:30 pm

Re: Custom 404 Page

Post by janus_zonstraal »

Why do you want error pages?
Sorry! My English is bat ;) !!!
bearsharktopus
Registered User
Posts: 11
Joined: Sat Nov 16, 2019 8:15 pm

Re: Custom 404 Page

Post by bearsharktopus »

I'm not sure if it matters why? But I'd like to have this:

Image

In our 404 page to give it a touch of fun, humor, and whimsy.
User avatar
david63
Registered User
Posts: 17976
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: Custom 404 Page

Post by david63 »

David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
bearsharktopus
Registered User
Posts: 11
Joined: Sat Nov 16, 2019 8:15 pm

Re: Custom 404 Page

Post by bearsharktopus »

Yes, but it doesn't work.
User avatar
EA117
Registered User
Posts: 1693
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Custom 404 Page

Post by EA117 »

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.
bearsharktopus
Registered User
Posts: 11
Joined: Sat Nov 16, 2019 8:15 pm

Re: Custom 404 Page

Post by bearsharktopus »

Thank you for the in-depth answer, EA!

Unfortunately, that seems to not have worked either.
Screen Shot 2019-11-17 at 1.40.44 PM.png
This is what the 404 page looks like now. And by now I mean now and also before, because it hasn't changed.
User avatar
Lumpy Burgertushie
Registered User
Posts: 67926
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Custom 404 Page

Post by Lumpy Burgertushie »

if you are getting that error page when trying to access a not existent phpbb page then there is something different about your board.

how about a link to your board so we can see that page.

robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?
User avatar
Tastenplayer
Registered User
Posts: 719
Joined: Thu Jul 03, 2014 9:20 pm
Location: Switzerland
Name: Jutta Koliofotis
Contact:

Re: Custom 404 Page

Post by Tastenplayer »

The problem is that if the image is inserted in the language file, it is not responsive.
error page.jpg
Lumpy Burgertushie wrote:
Sun Nov 17, 2019 6:49 pm
if you are getting that error page when trying to access a not existent phpbb page then there is something different about your board.
If I want to call up a page that does not exist in the forum, this comes to me, however:

Code: Select all

Information
No route found for "GET /questions"
Last edited by Tastenplayer on Sun Nov 17, 2019 7:03 pm, edited 1 time in total.
More of my styles you can find in my phpBB Style Board & More My styles -3.2.10-RC2
Be the best version of yourself rather than a bad copy of someone else!
Excuse me for my English, but I learned the language by speaking to people and not at school.
bearsharktopus
Registered User
Posts: 11
Joined: Sat Nov 16, 2019 8:15 pm

Re: Custom 404 Page

Post by bearsharktopus »

Lumpy Burgertushie wrote:
Sun Nov 17, 2019 6:49 pm
if you are getting that error page when trying to access a not existent phpbb page then there is something different about your board.

how about a link to your board so we can see that page.

robert
https://forum.homestuck.xyz
User avatar
Tastenplayer
Registered User
Posts: 719
Joined: Thu Jul 03, 2014 9:20 pm
Location: Switzerland
Name: Jutta Koliofotis
Contact:

Re: Custom 404 Page

Post by Tastenplayer »

@bearsharktopus
This picture comes to me sometimes(Not Found....) - this seems to be due to the server configuration. I think that you would have to insert another image on the server.
If I enter a page in the forum, which does not exist, comes always: no route found for....
Last edited by Tastenplayer on Sun Nov 17, 2019 7:11 pm, edited 1 time in total.
More of my styles you can find in my phpBB Style Board & More My styles -3.2.10-RC2
Be the best version of yourself rather than a bad copy of someone else!
Excuse me for my English, but I learned the language by speaking to people and not at school.
User avatar
Gumboots
Registered User
Posts: 330
Joined: Fri Oct 11, 2019 1:59 am

Re: Custom 404 Page

Post by Gumboots »

Tastenplayer wrote:
Sun Nov 17, 2019 6:54 pm
The problem is that if the image is inserted in the language file, it is not responsive.
That would only be because there is no CSS to make it responsive. You can always add some.
Post Reply

Return to “phpBB Custom Coding”