Last modified by Eleni Cojocariu on 2026/11/16 18:40

Show last authors
1 Make Nginx rewrite the path in front of XWiki so that URLs stop carrying the ##/bin/## servlet mapping, the approach to take when the instance is already behind Nginx, as described in [[Short URLs>>doc:documentation.xs.admin.urls.short-urls.WebHome]].
2
3 1. Serve ##/skins## and ##/resources## statically so that they never reach the servlet container, pointing the aliases at your own exploded XWiki web application.(((
4 {{code language="nginx"}}
5 location /skins {
6 alias /usr/lib/xwiki/skins;
7 }
8
9 location /resources {
10 alias /usr/lib/xwiki/resources;
11 }
12 {{/code}}
13 )))
14 1. Strip ##/bin## from incoming URLs and pass everything else to XWiki, keeping the ##proxy_set_header## directives of your [[HTTP Reverse Proxy for XWiki>>doc:documentation.xs.admin.installation.http-reverse-proxy.WebHome]] configuration.(((
15 {{code language="nginx"}}
16 # Answer the old "/bin" URLs with a redirect to the short form.
17 location /bin {
18 rewrite ^/bin/(.*)$ /$1 permanent;
19 }
20
21 # The container redirects the browser for "/", so send it to the home page instead.
22 location = / {
23 return 301 $scheme://$server_name/Main;
24 }
25
26 # Everything else goes to the servlet container.
27 location / {
28 proxy_pass http://localhost:8080/;
29 }
30 {{/code}}
31 )))
32 1. Map the ##action## servlet to ##/*## in ##WEB-INF/web.xml##.(((
33 {{code language="xml"}}
34 <servlet-mapping>
35 <servlet-name>action</servlet-name>
36 <url-pattern>/*</url-pattern>
37 </servlet-mapping>
38 {{/code}}
39 )))
40 1. Set ##xwiki.defaultservletpath## to an empty value in ##xwiki.cfg##, the key described with its ##xwiki.properties## counterpart on [[URL Configuration Properties>>doc:documentation.xs.admin.urls.short-urls.properties.WebHome]].(((
41 {{code language="none"}}
42 xwiki.defaultservletpath=
43 {{/code}}
44 )))
45 1. Restart Nginx and XWiki.
46 1. Open any page and read its URL. The servlet mapping is gone, and the old URLs still resolve through a redirect that the browser follows.(((
47 {{code language="none"}}
48 before http://server.com/bin/view/Sandbox/WebHome
49 after http://server.com/view/Sandbox/WebHome
50 {{/code}}
51 )))

Get Connected