Last modified by Admin on 2017/10/05 15:40

cogAllows configuration of the URL scheme used by XWiki to parse/serialize URLs
Developed by

XWiki Development Team

Active Installs0
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Enterprise

Installable with the Extension Manager


Even though it's already in use, this module is still in its infancy and the serialization part is not fully implemented yet.

This module is in charge of parsing/serializing XWiki URLs, based on a URL scheme specified in XWiki's configuration. In general terms the goal of this module is to allow implementing various URL schemes (i.e. various ways to specify XWiki URLs).

Specifically it uses the Resource API module and implements both a ResourceReferenceResolver and a ResourceReferenceSerializer to parse and serialize URLs. 

The following schemes are currently implemented:

  • standard
  • A filesystem URL Scheme has been started for exporting Resources to the filesystem and generating URLs to them (useful for the HTML Export for example). At the moment, only a few Resource Types are using it and most are still using the old XWikiURLFactory implementation classes.
  • A reference URL Scheme has been started but is not usable yet. It's meant to implement an Alternate Scheme being proposed in Design.

If you're looking to controlling the URLs you wish to use inside XWiki you should also check the Short URL tutorial, as one solution there is the use of a Rewrite Filter.


This module also offers some tools that can be reused. Specifically it provides:

  • An EntityReferenceResolver<String> resolver and an EntityReferenceSerializer<String> serializer implementations (with hint url) that can be used to parse/serialize EntityReference when used in URLs. The rationale is that Tomcat, for security reasons, doesn't support forward and backward slashes (/, \) in URLs by default. Thus, if a reference contains some reserved characters such as dot (.), colon (:), etc and you use a default serializer they'll be escaped using a backslash, leading to problems under Tomcat. So this resolver/serializer uses a different escape character (namely, it uses !). Example usage:
    private EntityReferenceResolver<String> urlResolver;

    private EntityReferenceSerializer<String> urlSerializer;

    private EntityReferenceSerializer<String> defaultSerializer;

    EntityReference reference = this.urlResolver.resolve("Some!.Page.Another page");
    assertEquals("Some!.Page.Another page", this.urlSerializer.serialize(reference));
    assertEquals("Some\.Page.Another page", this.defaultSerializer.serialize(reference));


The scheme to use is controlled by the url.format property in xwiki.properties:

#-# [Since 5.1M1]
#-# The id of the URL format to use. This allows to plug in different implementations and thus allows to completely
#-# control the format of XWiki URLs.
#-# The default is:
# url.format=standard

In addition, starting with XWiki 7.2M1 the URL scheme to use is set automatically in the Execution Context and can be modified at runtime. For example:

@Inject private URLContextManager urlContextManager;
String formatId = urlContextManager.getURLFormatId();

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.


Dependencies for this extension (org.xwiki.platform:xwiki-platform-url-api 9.8.1):

Created by Vincent Massol on 2013/08/06 18:20

Get Connected