[geeklog-devtalk] How to use url rewriting?

Dimitri Michaux Dimitri.Michaux at gmail.com
Wed Apr 6 15:26:56 EDT 2005


Thank you Dirk,

I understand it now. It is actually a really flexible way of handeling
this. I would have never come up with this, I would probably messed
around with .htaccess files.

But this way is better in some way. You don't need to know relative
expressions, but you still got that .php in there and you don't have an
extesion at the end.

Many thanks,
Dimitri


Dirk Haun schreef:


>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

>

>

>

>




More information about the geeklog-devtalk mailing list