I enabled UrlRewriteFilter as descripted at https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/ShortURLs/#HUrlRewriteFilter.
I added this into web.xml after <description>XWiki Application</description>
:
<!-- URL Rewrite Filters: http://www.tuckey.org/urlrewrite/ -->
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Then I addedd a /var/lib/tomcat9/webapps/xwiki/WEB-INF/urlrewrite.xml
file with the following code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite decode-using="null">
<rule>
<note>
Ensure that URLs ending with .gwtrpc are not modified.
Note: Not needed with XWiki 9.7+ since the GWT editor has been removed.
</note>
<from>^/(.*)\.gwtrpc$</from>
<to type="forward" last="true">-</to>
</rule>
<rule>
<note>
Ensure that URLs that must not be served by the Struts Servlet are not modified.
</note>
<from>^/((bin|resources|skins|asyncrenderer|rest|webdav|xmlrpc|wiki|webjars)/(.*)|robots\.txt)$</from>
<to type="forward" last="true">-</to>
</rule>
<rule>
<note>
For all other URLs we prepend the "/bin/" prefix so that they get routed to the XWiki Action Servlet.
</note>
<from>^/(.*)$</from>
<to type="forward">/bin/$1</to>
</rule>
<outbound-rule>
<note>
Rewrite outbound URLs to remove the "/bin" part when there are two paths after it.
</note>
<from>/bin/(.*)/(.*)$</from>
<to>/$1/$2</to>
</outbound-rule>
<outbound-rule>
<note>
Rewrite outbound URLs to remove the "/bin" part when there's a single path after it.
</note>
<from>/bin/(.*)$</from>
<to>/$1</to>
</outbound-rule>
<outbound-rule>
<note>
Rewrite outbound URLs to remove the "/bin" part it's the last path.
</note>
<from>/bin$</from>
<to>/</to>
</outbound-rule>
</urlrewrite>
That’s all.