Wiki source code of Accessing a wiki
Last modified by Thomas Mortagne on 2023/10/10
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
9.16 | 1 | {{box cssClass="floatinginfobox" title="**Contents**"}} |
2 | {{toc/}} | ||
3 | {{/box}} | ||
4 | |||
![]() |
13.1 | 5 | XWiki supports [[multi-tenancy>>Documentation.UserGuide.Features.ScalabilityPerformance]] which means your instance can have several wikis. This page helps you understand how to configure XWiki to access the correct wiki. Check [[XWiki URL Format>>Documentation.DevGuide.Architecture.URL Architecture.Standard URL Format]] to better understand the current URL scheme. |
![]() |
1.1 | 6 | |
![]() |
9.17 | 7 | XWiki supports 2 URL modes: Path-based and Domain based modes. |
![]() |
9.1 | 8 | |
9 | {{velocity}} | ||
![]() |
11.1 | 10 | {{info}}The documentation below is for XWiki 5.0 and beyond. For earlier versions, use [[this documentation>>path:$xwiki.getURL("Documentation.AdminGuide.Virtualization.AccessWiki.WebHome", "viewrev", "rev=5.1")]]{{/info}} |
![]() |
9.1 | 11 | {{/velocity}} |
![]() |
1.1 | 12 | |
![]() |
9.1 | 13 | = Path-based wiki access = |
![]() |
3.4 | 14 | |
![]() |
9.7 | 15 | This is the default mode if you haven't touched the XWiki configuration (##xwiki.virtual.usepath## property in the ##xwiki.cfg## file). |
![]() |
1.1 | 16 | |
![]() |
9.12 | 17 | The URL format for this mode is: ##http:~/~/host/xwiki/wiki/wikialias/view/Space/Page##. |
![]() |
1.1 | 18 | |
![]() |
9.1 | 19 | The important part of the URL is ##/wiki/wikialias##. Specifically it means: |
![]() |
9.13 | 20 | |
![]() |
9.6 | 21 | * ##wiki##: this is just a fixed value used by XWiki to identify the URL as a path-based URL. If you wish to set a value different than ##wiki## you can configure it in ##xwiki.cfg## with the property ##xwiki.virtual.usepath.servletpath##.((( |
![]() |
9.1 | 22 | {{warning}} |
23 | Don't forget to set the ##xwiki.authentication.logoutpage## property accordingly. Change the ##wiki## part in the property value for the right alias. | ||
24 | {{/warning}} | ||
25 | ))) | ||
26 | * ##wikialias##: this is used by XWiki to find the wiki descriptor (see below for more about wiki descriptors). The following algorithm is used: | ||
27 | ** First XWiki tries to find a page that contains a ##XWikiServerClass## object with the ##server## field having a value of ##wikialias##. If it finds one then it computes the name of the wiki by extracting it from that page name. Indeed, pages containing wiki descriptors must be named with the format ##XWikiServer<wikiid>##. For example if a page named ##XWikiServerTest## exists and it contains a ##XWikiServerClass## object with a ##server## field value of ##somewiki## then the URL ##http:~/~/host/xwiki/wiki/somewiki/...## will target the ##test## wiki (the value is lowercased from the page name when extracted). | ||
28 | ** If no wiki descriptor can be located then XWiki tries to find a page named ##XWikiServer<wikialias>## and having a ##XWikiServerClass## object in it. If it's found then the target wiki is ##wikialias##. | ||
29 | ** If no such page is found then the behavior depends on the value of the configuration property named ##xwiki.virtual.failOnWikiDoesNotExist## (located in your ##xwiki.cfg## file). If the value is ##0## (which is the default) then the wiki served is the main wiki. If the value is ##1## then an error saying that the wiki doesn't exist is displayed. | ||
![]() |
1.1 | 30 | |
![]() |
9.9 | 31 | Note that if no ##/wiki/wikialias## path is found in the URL then XWiki continues to look for a wiki using the domain-based algorithm explained below. |
![]() |
1.1 | 32 | |
![]() |
9.1 | 33 | = Domain-based wiki access = |
![]() |
1.1 | 34 | |
35 | {{info}} | ||
![]() |
9.1 | 36 | This was the default mode prior to XWiki 3.3. After the release of XWiki 3.3 the path-based mode was configured to be the default since it's the easiest to use. |
![]() |
1.1 | 37 | {{/info}} |
38 | |||
![]() |
9.1 | 39 | The URL format for this mode is: ##{{{http://domain/xwiki/bin/view/Space/Page}}}##. The information about which wiki is targeted is part of the ##domain## part of the URL. |
![]() |
1.1 | 40 | |
![]() |
9.1 | 41 | The following algorithm is used by XWiki: |
![]() |
9.13 | 42 | |
![]() |
9.1 | 43 | * First it tries to find a page that contains a ##XWikiServerClass## object with the ##server## field having a value of ##domain##. If it finds one then it computes the name of the wiki by extracting it from that page name. Indeed, pages containing wiki descriptors must be named with the format ##XWikiServer<wikiid>##. For example if a page named ##XWikiServerTest## exists and it contains a ##XWikiServerClass## object with a ##server## field value of ##somewiki## then the URL ##http:~/~/somewiki/xwiki/bin/...## will target the ##test## wiki (the value is lowercased from the page name when extracted). |
![]() |
9.8 | 44 | * If no wiki descriptor can be located then XWiki performs some checks: |
![]() |
9.1 | 45 | ** If the ##domain## value is an IP (e.g. 127.0.0.1, 85.65.12.36, etc.) or has the value of ##localhost## then XWiki considers you're targeting the main wiki |
46 | ** If not, then XWiki tries to split the domain name and takes the first part before the "." (dot) character. For example if you have a domain name of ##prefix.domain.com## then it extracts ##prefix##. It then performs some additional checks: | ||
![]() |
9.10 | 47 | *** if the value of ##prefix## is ##www## and there's no wiki alias named ##www## (i.e. there's no page with a ##XWikiServerClass## object having a ##server## field value of ##www##) then XWiki considers you're targeting the main wiki. |
![]() |
9.1 | 48 | *** If not, then XWiki tries to find a page named ##XWikiServer<prefix>## and having a ##XWikiServerClass## object in it. If it's found then the target wiki is ##prefix##. |
49 | *** If no such page is found then the behavior depends on the value of the configuration property named ##xwiki.virtual.failOnWikiDoesNotExist## (located in your ##xwiki.cfg## file). If the value is ##0## (which is the default) then the wiki served is the main wiki. If the value is ##1## then an error saying that the wiki doesn't exist is displayed. | ||
![]() |
5.1 | 50 | |
![]() |
9.1 | 51 | {{info}} |
52 | Note that in this mode you need to configure your DNS or modify your ##/etc/hosts## file in your operating system (see [[Hosts file documentation on Wikipedia>>http://en.wikipedia.org/wiki/Hosts_file]] for details). | ||
53 | {{/info}} |