[geeklog-devtalk] How to use url rewriting?

Dirk Haun dirk at haun-online.de
Wed Apr 6 14:26:59 EDT 2005


Dimitri,


> * I'm not sure, but I think I have to use the function

> COM_buildURL(). This functions will then return a more readable

> url if url rewriting is enabeld. Is this all? Or is there about it?


Yes, that's all. You feed it with the URL you would use without rewriting
and it either returns it unchanged (if rewriting is off) or "rewritten".



> * Who does the php scripts know what the rewritten url means?

> (/article.php?story=title doesn't look the same as

> /article.php/title) Is there more about it? Or does it just work?


Have a look at code that uses it. For example, the static pages plugin
(staticpages/index.php):

COM_setArgNames (array ('page', 'mode'));
$page = COM_applyFilter (COM_getArgument ('page'));
$mode = COM_applyFilter (COM_getArgument ('mode'));

COM_setArgNames tells Geeklog that the first parameter in the URL is the
page and the second is the mode. The plugin then uses COM_getArgument to
actually request those parameters.

This will work both with and without rewriting being activated.

One important thing to notice is that the order of arguments will matter
now. So while myscript.php?foo=42&bar=0 and myscript.php?bar=0&foo=42 are
equivalent, this is no longer the case when using the URL rewriting
class. So make sure you always pass the parameters in the same order.

bye, Dirk


--
http://www.haun-online.de/
http://www.handful-of-sparks.de/




More information about the geeklog-devtalk mailing list