I’m shortening URLs with https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/ShortURLs/
with UrlRewriteFilter.
i changed upload.js to request.open(‘POST’, this.formData.action + ‘?form_token=’+this.formData.additionalFields[‘form_token’] + ‘&xredirect=’ + escape(this.formData.additionalFields[‘xredirect’]));
my web.xml
cat ./webapps/ROOT/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<!-- Notes:
* metadata-complete="true" is used to disable scanning the web application and its libraries for classes that use
annotations to define components of a web application (Servlets etc.). Thus leading to a faster startup.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
<!-- "absolute-ordering" specifies which web fragment JARs (according to the names in their WEB-INF/web-fragment.xml
files) have to be scanned for SCIs (javax.servlet.ServletContainerInitializer), fragments and annotations.
An empty <absolute-ordering/> element configures that none are to be scanned, thus leading to a faster
startup. -->
<absolute-ordering />
<display-name>XWiki</display-name>
<description>XWiki Application</description>
<!-- Filter in charge of deciding whether to call the ResourceReferenceHandler Servlet (currently used to handle new
Resource Types registered as Components) or instead to continue with the rest of the filters and mappings below.
In the future, the goal is to move more and more Resource handling using the ResourceReferenceHandler Servlet and
remove the Legacy Action Servlet at some point.
Note: it is important that this filter be the first filter declared (and thus executed). -->
<filter>
<filter-name>RoutingFilter</filter-name>
<filter-class>org.xwiki.resource.servlet.RoutingFilter</filter-class>
</filter>
<!-- URL rewriting filter (for short URLs) -->
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<logLevel>sysout:DEBUG</logLevel>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
my urlrewrite.xml
cat ./webapps/ROOT/WEB-INF/urlrewrite.xml
<?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 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 are three paths after it.
</note>
<from>/bin/(.*)/(.*)/(.*)$</from>
<to>/$1/$2/$3</to>
</outbound-rule>
<outbound-rule>
<note>
Rewrite outbound URLs to remove the "/bin" part when there are four paths after it.
</note>
<from>/bin/(.*)/(.*)/(.*)/(.*)$</from>
<to>/$1/$2/$3/$4</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>
now i get 404 eror:
Type Status Report
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.