Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-06-08 06:34:14

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

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

#2 2008-06-08 09:29:23

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#3 2008-06-08 14:22:35

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

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

#4 2008-06-08 19:12:48

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#5 2008-06-08 20:22:21

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: The request of a "404 Not Found" [Solved]

You could also use ltrim(page_url(), '/'). Unnoticeably faster by ~3E-5 seconds :).

Offline

#6 2008-06-09 04:56:17

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

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

Board footer

Powered by FluxBB