[geeklog-devtalk] How to use url rewriting?
Richard S. Westmoreland
richardsw at suscom.net
Wed Apr 6 14:41:00 EDT 2005
----- Original Message -----
From: "Dirk Haun" <dirk at haun-online.de>
To: <geeklog-devtalk at lists.geeklog.net>
Sent: Wednesday, April 06, 2005 2:26 PM
Subject: Re: [geeklog-devtalk] How to use url rewriting?
> 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
Wow, I didn't realize the rewrite code was reusable. When I setup my
topic.php page, I copied and customized a small routine to accomplish the
url rewrite.
Blaine - remember our discussion about creating static links just for the
topic index? That way the search engines would visit it more often in order
to visit the threads. So based on Dirk's explanation, you could use already
existing GL functions to accomplish it. So instead of
www.portalparts.com/forum/index.php?&forum=2 it would be
www.portalparts/forum/2.
I better continue this conversation back at your site...
Rick
More information about the geeklog-devtalk
mailing list