Wiki source code of Configure Tomcat to Allow Slash and Backslash in Page Names
Last modified by superadmin on 2026/11/25 21:30
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | 1. Allow ##/## and ##\## in [[Page names>>doc:documentation.xs.user.page.titles-names.WebHome||anchor="HPageNames"]] in the "Name Strategies" administration section, by removing them from the forbidden characters of the [[Model Validation Strategy>>extensions:Extension.Model.Validation.Default.WebHome]]. | ||
| 2 | 1. Enable encoded slash support in Tomcat by adding the system property:((( | ||
| 3 | {{code language="none"}} | ||
| 4 | -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true | ||
| 5 | {{/code}} | ||
| 6 | ))) | ||
| 7 | 1. Enable backslash support in Tomcat by adding the system property:((( | ||
| 8 | {{code language="none"}} | ||
| 9 | -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true | ||
| 10 | {{/code}} | ||
| 11 | ))) | ||
| 12 | 1. Add both properties to CATALINA_OPTS to make the configuration persistent:((( | ||
| 13 | {{code language="none"}} | ||
| 14 | CATALINA_OPTS="$CATALINA_OPTS \ | ||
| 15 | -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true \ | ||
| 16 | -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true" | ||
| 17 | {{/code}} | ||
| 18 | ))) | ||
| 19 | 1. Configure ##CATALINA_OPTS## in your environment using the appropriate mechanism for your system (for example ##setenv.sh##, ##setenv.bat##, or system-wide Tomcat configuration files). | ||
| 20 | 1. Restart Tomcat to apply the changes. | ||
| 21 | 1. Configure the [[HTTP reverse proxy>>doc:documentation.xs.admin.installation.http-reverse-proxy.WebHome]] in front of the Servlet Container, if there is one, to pass ##%2F## and ##%5C## through undecoded. [[Apache HTTP Server>>doc:documentation.xs.admin.installation.http-reverse-proxy.apache-key-configurations.WebHome]] needs [[##AllowEncodedSlashes NoDecode##>>https://httpd.apache.org/docs/current/mod/core.html#allowencodedslashes]] and the ##nocanon## option on its [[##ProxyPass##>>https://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass]] line, and answers ##404## for such a URL without them; [[NginX>>doc:documentation.xs.admin.installation.http-reverse-proxy.nginx-key-configurations.WebHome]] needs a [[##proxy_pass##>>https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass]] carrying no path, and otherwise forwards a normalized path that reaches a different Page. | ||
| 22 | 1. Create a Page whose name contains a slash or a backslash. XWiki saves it and serves its URL without returning an HTTP 400 error. |