Wiki source code of Change the Wiki Path Segment
Last modified by Eleni Cojocariu on 2026/10/20 17:57
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | In a path-based URL such as ##/xwiki/wiki/support/view/Main/WebHome## the ##wiki## segment is the fixed marker that [[tells XWiki to read the wiki from the path>>doc:documentation.xs.admin.wikis.url-resolution.WebHome]], and renaming it means changing three files rather than one. | ||
| 2 | |||
| 3 | 1. Set the new segment in ##WEB-INF/xwiki.properties##:((( | ||
| 4 | {{code language="properties"}} | ||
| 5 | url.standard.multiwiki.wikiPathPrefix = site | ||
| 6 | {{/code}} | ||
| 7 | ))) | ||
| 8 | 1. Set the same value in ##WEB-INF/xwiki.cfg##:((( | ||
| 9 | {{code language="properties"}} | ||
| 10 | xwiki.virtual.usepath.servletpath=site | ||
| 11 | {{/code}} | ||
| 12 | |||
| 13 | The filter that rewrites form submissions reads this key and not the one above, so a page saved from a subwiki is sent to the wrong URL while only the first file is changed. | ||
| 14 | ))) | ||
| 15 | 1. Point the ##action## servlet at the new segment in ##WEB-INF/web.xml##, replacing the mapping that carries the old one:((( | ||
| 16 | {{code language="xml"}} | ||
| 17 | <servlet-mapping> | ||
| 18 | <servlet-name>action</servlet-name> | ||
| 19 | <url-pattern>/site/*</url-pattern> | ||
| 20 | </servlet-mapping> | ||
| 21 | {{/code}} | ||
| 22 | |||
| 23 | The servlet container routes on this mapping alone, so without it every URL built with the new segment is answered with a 404. | ||
| 24 | ))) | ||
| 25 | 1. Replace the old segment in ##xwiki.authentication.logoutpage##, further down ##WEB-INF/xwiki.cfg##. The value is a pattern, and its third alternative is the path-based one:((( | ||
| 26 | {{code language="properties"}} | ||
| 27 | xwiki.authentication.logoutpage=(/|/[^/]+/|/site/[^/]+/)logout/* | ||
| 28 | {{/code}} | ||
| 29 | |||
| 30 | {{warning}} | ||
| 31 | Leaving this one behind is the trap of the procedure: nothing reports an error, but the logout URL of a subwiki stops matching the pattern, so it is served as an ordinary request and the user is never signed out. | ||
| 32 | {{/warning}} | ||
| 33 | ))) | ||
| 34 | 1. Restart XWiki. All three files are read once, at startup. | ||
| 35 | 1. Open a subwiki through the renamed segment and confirm that it answers, that its own links carry the new segment, and that logging out of it works:((( | ||
| 36 | {{code language="none"}} | ||
| 37 | http://myfarm.example.org/xwiki/site/support/view/Main/WebHome | ||
| 38 | {{/code}} | ||
| 39 | ))) |