[Klone-users] Getting the URI of a non existing file from within a 404 error page

Stefano Barbato barbato at koanlogic.com
Wed Jul 23 06:07:08 EDT 2008


Hi Christian,

you cannot get just the uri part of the request but you can still get  
the whole request line sent by the client:

---[ my-404.kl1 ]---
<body>
404:

<%
     io_printf(out, "request line: %s",  
request_get_client_request(request));
%>

</body>
--------------------

To have custom 404 pages you can redirect to the proper page after  
parsing the value returned by the request_get_client_request()  
function above or, if that makes sense in your configuration, define  
different virtual hosts to handle different sections/dirs:

---[ kloned.conf ]---
  ... snip...

app_http
{
     type            http
     addr.type       IPv4
     addr.port       8080
     dir_root        /www

     bikes.mysite.com
     {
         dir_root        /bikes/
         error.404       /bikes-404.kl1
     }

     cars.mysite.com
     {
         dir_root        /cars/
         error.404       /cars-404.kl1
     }
}

---------------------

bye!
s



On 23/lug/08, at 11:12, Christian Kelinski wrote:

> Hi,
>
> I recently added a 404 error page to my kloned-webapp. It works but
> I've a problem with getting the URI of the non existing requested
> page.
>
> The function request_get_uri seems to be what I'm looking for, but the
> string returned by it only holds the URI of the 404 page, not the one
> requested. Other functions from this group
> (http://www.koanlogic.com/klone/api/html/group__request__t.html)
> either returning the URI of the 404 page (sometimes with the dir_root
> in front of it) or NULL.
>
> So is there any way to get this URI?
>
> And as an additional question: I haven't tried it, but is there any
> way to define more then one 404 error page, let's say one for /dirA
> and all its sub dirs and another one for /dirB and all its sub dirs?
>
> Greetings
> Christian
>
> _______________________________________________
> Klone-users mailing list
> Klone-users at koanlogic.com
> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>




More information about the Klone-users mailing list