[pmwiki-users] Internal redirect based on referrer

Eric Celeste efc.dev at gmail.com
Tue Dec 4 10:28:26 CST 2007


This turned out to be quite simple, but I wanted to post a solution for the
record...
There is a useful function called Redirect() in PmWiki's core functions. To
use it, just call Redirect($pagename).

For example... In a group.php config file I can include:

$ref = $_SERVER["HTTP_REFERER"];
$pattern = '/collection=([^\&]*).*item=([^\&]*)/';
if (preg_match($pattern,$ref,$matches)) {
$collection = $matches[1];
$item = $matches[2];
Redirect(MakePageName("","Discuss.$collection$item"));
}
Redirect("Discuss.Sorry");

...Eric

On 11/21/07, Eric Celeste <efc.dev at gmail.com> wrote:
>
> I'd like to have PmWiki choose which page to show based on the referrer to
> PmWiki without depending on external rewriting of the addresses involved.
> For example:
>
>
>     ... if my wiki is "http://target.com/pmwiki.php",
>
>
>     ... a link on " http://source.com/foo" to "
> http://target.com/pmwiki.php?n=Bob"
>         would end up retrieving "Bob/foo"
>
>     but
>
>
>     ... a link on "http://source.com/bar" to "http://target.com/pmwiki.php?n=Bob
> "
>         would end up retrieving "Bob/bar"
>
>
> I know how to get and parse the referrer in PHP, but I am not clear on how
> to get PmWiki to redirect its efforts toward showing a page other than the
> one it was called to show.
>
>
> Any quick hints as to how to go about this in the Bob.php group config
> page?
>
>
> Thanks,
> ...Eric
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-users/attachments/20071204/ca04c41c/attachment.html 


More information about the pmwiki-users mailing list