Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#248 portable URL for local host

Linking
closed
Reini Urban
1
2012-10-11
2004-02-27
Anonymous
No

There is no way to reference the current host in URL
with bracket (ie [ http://hostAdd:80/path] where path
is a page on the local host.

It is not a good idea to put the real server name
because if the wiki is moved to another server the link
will be broken .

An idea is to allow the placeholder "localhost" that
will be replace with the real server address by the
wiki engine.
Here is a patch that provide this facility :

file stdlib.php function LinkURL().

diff wikiwiki/lib/stdlib.php phpwiki-1.3.7/lib/stdlib.php
241,244c241,244
< $resUrl = preg_replace
("#http://(localhost|127.0.0.1)/(.*)#",SERVER_URL .
"/" . PHPWIKI_DIR . "\2", $url);
<
< $link = HTML::a(array('href' => $resUrl),
<
PossiblyGlueIconToText($resUrl, $linktext));


    $link = HTML::a(array('href' => $url),
                    PossiblyGlueIconToText($url,

$linktext));

Discussion

  • Logged In: YES
    user_id=252428

    I think phpwiki: does that for you, but your patch does no
    harm.