Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
The request of a "404 Not Found" [Solved]
Hello,
When a bad request is sent to a website, we have a 404 Not Found server answer, and we have two interesting tags <txp:error_status />
and <txp:error_message />
for our error template.
Can we grab the bad request somewhere ? Then we can have an error template that return :
404 Not Found the article bad article doesn’t exist on this server
Plus : this bad request can be grabbed by some statistics tools.
Thanks
Last edited by fpradignac (2008-06-08 14:32:53)
françois
Offline
Re: The request of a "404 Not Found" [Solved]
I use http://thebombsite.com<txp:page_url />
over at The Bombsite to return the full URL requested. I suppose you could use the TXP tag on it’s own though you have the problem of the leading “forward slash”.
Can’t help with the statistics side of things though errors are usually collated by server software that you can access through your cPanel.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: The request of a "404 Not Found" [Solved]
Thanks Stuart.
When I use <txp:page_url />
, the requested value begin with a slash like you said.
So I just have a look at the function page_url()
and deleted the slash like this (on the error_default template) :
<h4>«<b><txp:php>print eregi_replace(“^/”,”“,page_url($request_uri));</txp:php></b>» : <txp:error_status /></h4>
<h5><txp:error_message /></h5>
Then I can display something like this, if I send test-bad-request in my browser :
« test-bad-request » : 404 Not Found
The requested resource was not found.
For the stats, I use BBClone and a plugin to integrate it in TXP, so I will hacked it using page_url($request_uri)
to grab the requested value.
Last edited by fpradignac (2008-06-08 14:34:57)
françois
Offline
Re: The request of a "404 Not Found" [Solved]
I really should look at PHP. ;)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: The request of a "404 Not Found" [Solved]
You could also use ltrim(page_url(), '/')
. Unnoticeably faster by ~3E-5 seconds :).
Offline
Re: The request of a "404 Not Found" [Solved]
Thanks jm great peace of code !
Much more simple actually,
…and win a lot of time ;-))))))
Last edited by fpradignac (2008-06-09 05:08:08)
françois
Offline