Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-07 21:15:33

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Custom Error Pages

I’m trying to get Textpattern’s custom error page feature to work with mod-security. The standard 404 handler works as expected. But what about other errors that might be generated by mod-security, such as 400, 403, 501, etc.? These are not being handled. I have tried adding Apache ErrorDocument commands to my Apache configuration, but that does not seem to be helping, and I am unclear on how exactly these mechanisms interact (Apache ErrorDocument + Mod-Security + Textpattern).

If anyone has some experience in getting this to work, I’d love to hear how you did it.

Thanks!

Offline

#2 2008-11-11 07:54:00

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Custom Error Pages

Hmmm. Nobody has any idea how this works? Maybe the devs could chime in?

Offline

#3 2008-11-11 08:19:11

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Custom Error Pages

Textpattern doesn’t (need to) handle any error besides 404. In any Apache environment I’ve stumbled across these past years, ErrorDocument XXX /foo.bar worked for 403 or 500 stati, so we’d be better off if you could provide a little more information. Apache’s error_log or access_log might serve as a starting point.

Possibly related: FAQ.

Offline

#4 2008-11-11 09:07:57

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Custom Error Pages

I was under the impression that I could create an error page in Textpattern named error_xxx where xxx is the http error code (error_503, etc.) and that this page would be automagically displayed when apache generates the matching error. Is that not an accurate impression?

I have tried to create such pages, but they are not invoked as expected…

Offline

#5 2008-11-11 09:26:54

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Custom Error Pages

It’s a little bit more complex. Textpattern won’t even get a chance to handle all 500 errors, as some of those might be caused by an invalid line in .htaccess and therefore prematurely end all of Apache’s request processing.

Basically, Textpattern handles all of 404, plus status 500 when the root cause is located in some condition which Textpattern would be able to detect (currently, a failed file download is the only reason for a 500 response in Textpattern).

Anything else, especially 401 or 403, are up to Apache. Apache’s control flow might cause a transfer of the request back to Textpattern at some occasions (missing ErrorDocument being the most prominent), as indicated in the FAQ entry mentioned above.

Offline

#6 2008-11-11 12:00:36

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Custom Error Pages

Also, rvm_privileged lets handle error 503, and yes, then you can create a error_503 page template for customizing it.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2008-11-11 12:09:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Custom Error Pages

^^ And so does rvm_maintenance: error_503.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2008-11-11 13:00:54

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Custom Error Pages

Mmm… I think I wanted to mean rvm_maintenance… but not sure… Yeah, definitely, I wanted to say rvm_maintenance.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#9 2008-11-11 13:46:35

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Custom Error Pages

Request granted. Say it!

Offline

#10 2008-11-11 18:41:10

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Custom Error Pages

OK, so in theory I should be able to create a new section (error) for error pages and use Apache’s ErrorDocument directive to send errors to those pages, right? But this is not working. For example, when I submit a form (POST) that contains data that mod-security rejects with a 501 error, the redirect does not occur. Instead, the form simply refuses to submit and refreshes itself (losing all form field data).

But if I change the ErrorDocument directive to use a static html page, it works…

Offline

Board footer

Powered by FluxBB