|
PITS /
00526Summary: Use relative urls by default
Created: 2005-09-15 13:10
Status: Suspended
Category: CoreCandidate
From: Pm
Assigned:
Priority: 5552
Version: 2.0.5
OS:
Description:
At present, PmWiki constructs full absolute urls for referring to other pages in the wiki; i.e., for a link to Main.WikiSandbox it generates If PmWiki used the latter, then distinctions between server names and Pm has tried using relative urls in the past as the default (including in the early 2.0.devel series), but some sites have run into problems with relative urls and dealing with forms, especially for things like the CleanUrls recipes. But perhaps these can be solved, which is why this entry is here. Others can help test for problems with relative urls by setting
and letting us know below if their site continues to work properly. (Note, be sure to test uploads, editing, and searching.) --Pm See also PITS:00527 for a related issue. With the above settings a local installation under windows and with use of PHP 4.4 and Abyss Webserver does not work. $ScritpUrl gets the absolute path on the drive to the script instead of http://127.0.0.1/pathtopmwiki as it should This settings should work: $ScriptUrl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; or $ScriptUrl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; For farms following settings work (I don't really know how to automate the first line, second part, when called from an intermediate index.php): $ScriptUrl = 'http://'.$_SERVER['HTTP_HOST'].'/pmwiki/pmwiki.php';
-- Klonk September 20, 2005, at 01:21 PM My above suggested setting has some addtitional flaws: it does not support https and the farm setting does not work correctly that way. -- Klonk September 21, 2005, at 02:40 AM This is what I found works with standard setup and covers also a secure call: $ScriptUrl = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$PubDirUrl = preg_replace('#/[^/]*$#', '/pub', $ScriptUrl, 1);
This is what I consider good for a farm setup and works for me (within farmconfig.php): $ScriptUrl = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$FarmPubDirUrl = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].'/pmwiki/pub';
$PubDirUrl = $FarmPubDirUrl;
within the local config.php (assuming that the farmdirectory is at the same level as the pmwiki directory): $UploadUrlFmt = preg_replace('#/[^/]*$#', '/uploads', $ScriptUrl, 1);
-- Klonk I should note that I've run into some environments or configurations where $_SERVER['PHP_SELF'] isn't set properly, which is why PmWiki uses $_SERVER['SCRIPT_NAME'] instead. --Pm Pm, your're right. Because of that I also ran into several problems. Just one additional comment to the above setting of -- Klonk Hi I am pretty new over here, but ran into the https problem with my second installation :-) Cause I like to work generic I used: WikiFarmAlternative I first hacked pmwiki.php to use relative URL's to get things working with https. But not knowing if this would give any issues I started search the Docs and found PITS:00527 and this article. I tried the Unfortunate switching to relative addressing in the configfile doesn't do the trick. I have always been a fan of generic solutions. So avoiding the relative addressing problem mentioned above by PM and having automatically switching from http to https right looks like the most preferable path to go. In PITS:00527 I found:
Which has absolute path and http/https switching. Having put this in PmWiki.php both http and https page from the same farm set-up work OK. So why not just fix this problem right at the core and use this, or a other solution, detecting if the URL has a http or https prefix and switching the prefic accordingly. --Bart |