Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-04-22 21:37:33

snkhan
Member
From: Leicester, UK.
Registered: 2004-07-20
Posts: 57
Website

error_default returns blank page

Hi guys,

I’ve done a search of the forums (and Google, naturally), however, I can’t seem to get my 404 page working. I have replaced the content of the error_default page with:

<txp:php> header(‘HTTP/1.0 404 Not Found’);
header('Location: http://snkhan.co.uk/oops/error404.php'); </txp:php>

However, all this does is show a blank page. TP is sending the user to this error_default page because if I type anything else after the header above then this too is displayed.

My TP install is off-the-root, i.e., http://snkhan.co.uk/journal

I’m at a loss to understand what I might be doing wrong, and would be grateful for any help or suggestions.

Saj

Offline

#2 2011-04-22 22:33:10

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: error_default returns blank page

Something like this maybe?

header("HTTP/1.0 404 Not Found"); 
include("/path/to/root/oops/error404.php");

Offline

#3 2011-04-23 06:22:33

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: error_default returns blank page

TXP already sends the 404 header. You don’t need to (nor shouldn’t).

Offline

#4 2011-04-23 07:37:04

snkhan
Member
From: Leicester, UK.
Registered: 2004-07-20
Posts: 57
Website

Re: error_default returns blank page

Thanks, the include is working, however one of the includes called at the bottom of the page is returning a fatal error – possibly because we have included the error file rather than redirected to it. Anyway of getting the header: location to work in this instance?

http://snkhan.co.uk/journal/ThisPageDoesNotExist

Offline

#5 2011-04-23 09:17:02

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: error_default returns blank page

snkhan wrote:

Anyway of getting the header: location to work in this instance?

Isn’t redirecting really bad practice? “Oops, seems that I accidentally typed car, instead of cat, I just change that one letter and…”

Thanks, the include is working, however one of the includes called at the bottom of the page is returning a fatal error – possibly because we have included the error file rather than redirected to it.

What is the contents of the error404.php? What is the error? If you just want to display the contents (or output) of error404.php, you can use file_get_contents() instead of include which would evaluate PHP code.

Offline

#6 2011-04-23 11:46:45

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: error_default returns blank page

Is there a reason you can’t just create a page template ‘error_404’ and copy the content of your error404.php into it?

Offline

Board footer

Powered by FluxBB