Configure Short URLs with Apache HTTP Server

Last modified by Eleni Cojocariu on 2026/10/30 18:38

Steps

Make Apache HTTP Server 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 Apache, as described in Short URLs.

  1. Serve /skins and /resources from Apache so that they never reach the servlet container, pointing the aliases at your own exploded XWiki web application (webapps/ROOT on Tomcat).
    Alias /skins /usr/local/xwiki/skins
    Alias /resources /usr/local/xwiki/resources
    
    RewriteEngine on
    
    RewriteRule     ^/+skins                -       [L]
    RewriteRule     ^/+resources($|/.*)     -       [L]
  2. Proxy every other request to XWiki, replacing localhost:8080 with your own servlet container address.
    ## The container redirects the browser for "/", so proxy it straight to the home page instead.
    RewriteRule     ^/*$       http://localhost:8080/Main/             [P,L]
    ## Everything else goes to the servlet container.
    RewriteRule     .*         http://localhost:8080%{REQUEST_URI}    [P,L]
    
    ProxyPassReverse  /        http://localhost:8080/
  3. Map the action servlet to /* in WEB-INF/web.xml.
    <servlet-mapping>
      <servlet-name>action</servlet-name>
      <url-pattern>/*</url-pattern>
    </servlet-mapping>
  4. Set xwiki.defaultservletpath to an empty value in xwiki.cfg, the key described with its xwiki.properties counterpart on URL Configuration Properties.
    xwiki.defaultservletpath=
  5. Restart Apache and XWiki.
  6. Open any page and read its URL. The servlet mapping is gone, and the home page is reached without a redirect the browser can see.
    before   http://server.com/bin/view/Sandbox/WebHome
    after    http://server.com/view/Sandbox/WebHome
    after    http://server.com/                            shows Main.WebHome

FAQ

Do I still need the X-Forwarded-* headers?

Yes. This procedure changes nothing about the reverse-proxy setup, which is covered by the page linked below.

Related

Get Connected