SID-02238: Twiki pointing to wrong URL
| Status: |
Answered |
TWiki version: |
6.0.2 |
Perl version: |
5.22.1 |
| Category: |
CategoryHosting |
Server OS: |
Ubuntu 16.4 |
Last update: |
9 years ago |
I have made a twiki server which is working fine in my local network. The main twiki web is loading at
http://172.16.XX.XX/do/view/Main
, so the all other twiki webs. My institute has provided an equivalent link for Main twiki link at
http://some.domain.edu/TwikiPhysics/do/view/Main
for making twiki public.
With this public link twiki is not working properly. When I open the page
http://some.domain.edu/TwikiPhysics/do/view/Main
, the css fails to load.
A twiki link
http://some.domain.edu/TwikiPhysics/do/view/TWiki/WelcomeGuest
is appearing as
http://some.domain.edu/do/view/TWiki/WelcomeGuest
. It seems that twiki is reading the first "/" separated string from the url. This is why it is looking for css at wrong place.
How do I ask twiki to look at
http://some.domain.edu/TwikiPhysics/
instead of
http://some.domain.edu/
for all twiki webs?
--
TWiki Guest - 2016-08-09
Discussion and Answer
Having one TWiki installation work simultaneously under two different URLs is tricky. Both TWiki and Apache have information about 1) URL paths and 2) file system paths in their configuration files. But while Apache can make a difference between the two links by using the
VirtualHost directive, TWiki has just one
LocalSite.cfg file. CSS files are an obvious symptom of the problem, but there are also issues with HTTP redirections where TWiki has to provide absolute URLs. That's why I am
not recommending a "solution" to use mod_rewrite to change
TWikiPhysics/$url to
/$url.
The only fairly easy method I know about is to have actually two TWiki installations - not two complete ones, but two disjunct
lib directories (where
LocalSite.cfg is located) and
bin directories (which would be the different entry points for your Virtual hosts). Both installations can share their
data and
oub directories!
--
Harald Jörg - 2016-08-09
Thanks for your reply. I think my question was confusing let me try to elaborate it bit more. Actually we don't want two different URLs for our server, only we want
http://some.domain.edu/TwikiPhysics/
to point to twiki root. Our institute have provided us with the link
http://some.domain.edu/TwikiPhysics/
using reverse proxy and this link is pointing to
http://172.16.XX.XX/do/
i.e our local server. But when I open the page
http://some.domain.edu/TwikiPhysics/do/view/Main
, the css fails to load. If we look on the page all the links points to
http://some.domain.edu/
not to
http://some.domain.edu/TwikiPhysics
. Hope my question is clear. Thanks in advance
--
TWiki Guest - 2016-08-10
The easiest solution would then, in my opinion, be to move your local installation from
http://172.16.XX.XX/do/view/Main
to
http://172.16.XX.XX/TwikiPhysics/do/view/Main
.
The background: With your current reverse proxy and TWiki settings, TWiki gets requests for
/do... (scripts) and
/pub (CSS and stuff), and when it creates links in its HTML pages, it creates links to
/do and
/pub. TWiki does
not try to calculate relative URLs to convert
/pub to
../pub (and there are valid reasons for that), so there's nobody there to sneak the
TwikiPhysics part into the URLs before the HTML page hits the browser. As far as I know, the reverse proxy rewrites URLs in redirects, but does not change the contents of HTML pages.
You could cheat to some extent by setting
{PubUrlPath} to
/TwikiPhysics/pub in your TWiki configuration (I guess you have
/pub), and I guess this will work for CSS, images, and javascript. But I assume that doing the same for
{ScriptUrlPath} (i.e. setting to
/TwikiPhysics/do), will confuse TWiki because the actual requests from the reverse proxy do no longer match
{ScriptUrlPath}, so TWiki will not be able to parse web and topic from the request URL.
--
Harald Jörg - 2016-08-10
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.