Question How to change the home page destination when you enter http://localhost:8080/xwiki
Answer

Since XE 1.5M2

Using a Redirect on Main.WebHome

This is the simplest of all. Edit Main.WebHome and type: $response.sendRedirect($xwiki.getURL('Space.Page')) where Space.Page is the page you wish to redirect to.

Using the Redirect Servlet

Edit WEB-INF/web.xml, locate the section with the servlet responsible for the redirect (the one with the line <servlet-class>com.xpn.xwiki.web.HomePageRedirectServlet</servlet-class>), and change that section to contain something like:

<servlet>
    <servlet-name>redirectHomeServlet</servlet-name>
    <servlet-class>com.xpn.xwiki.web.HomePageRedirectServlet</servlet-class>
    <init-param>
      <param-name>homePage</param-name>
      <param-value>bin/NewHomeSpace/NewHomePage</param-value>
    </init-param>
  </servlet>

Before XE 1.5M2

Since the above setting for the homepage redirect servlet was recently introduced, in older versions of XWiki you must alter the source code and recompile that class. For this, you must first checkout the sources, alter com.xpn.xwiki.web.HomePageRedirectServlet and build the modified classes, then copy the resulting class to your installation (in the WEB-INF/classes/com/xpn/xwiki/web/ directory). You only need to copy one class. It is better to checkout the sources for the exact version you are using, in order to ensure maximum compatibility, although any version should work fine.

An easier way is to copy a recent trunk version of this class and then configure it as described above. This class does not have other dependencies on the XWiki platform code, so you don't have to upgrade the whole platform.

The other alternatives

Using the redirect servlet is not the only way to accomplish this. You could also (in order of "cleanliness"):

  1. Use mod_alias in an Apache httpd frontend to redirect (RedirectMatch ^/xwiki/?$ /xwiki/bin/HomeSpace/HomePage)
  2. Use mod_rewrite in an Apache httpd frontend to display the contents of the desired page.
  3. Make all the changes described in the Short URLs guide, then configure in WEB-INF/xwiki.cfg the properties xwiki.defaultweb=NewDefaultSpace and xwiki.defaultpage=NewDefaultPage; after that, accessing the default URL should not redirect to, but actually display the contents of the main page.
  4. In WEB-INF/web.xml change the welcome-file-list section to include other files (index.html for an HTML redirect, or index.jsp for a JSP redirect). This means:
    1. edit WEB-INF/web.xml, locate the welcome-file-list section and add something like <welcome-file>index.html</welcome-file> (or index.jsp) above the <welcome-file>redirect</welcome-file> line;
    2. add a file called index.html (or .jsp) in the application directory (the top level one, along WEB-INF, skins and templates), and enter the content that should redirect to the desired home page.
    3. if you used a JSP file, make sure your container has support for this kind of files.
Version 6.2 last modified by Vincent Massol on 01/12/2008 at 13:59

Comments 1

mikhael santos | 16.06.2008 at 11:33 AM
Can Anybody answer this

Attachments 0

No attachments for this document

Creator: JPaul Goncalves araujo on 2008/04/24 10:58
This wiki is licensed under a Creative Commons license
1.5.2.12758