Apache URL Rewriting Instructions for Confluence Wiki Running on Windows Server

Here are some steps to configure Apache URL rewriting because I was migrating from dokuwiki to Confluence wiki.

1) Download Url Rewrite Filter – http://www.tuckey.org/urlrewrite/#download

2) Download the zip and extract it into your Confluence directory — E:clientsConfluenceconfluence-3.2.1_01-stdconfluenceWEB-INF (in the WEB-INF directory, you will see the urlrewrite.xml file).

3) Copy the web.xml to your WEB-INF directory and add the following to your WEB-INFweb.xml (add it near the top above your servlet mappings)

<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>

<filter-mapping>

<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

4) Add your own URL rewrite rules to the WEB-INFurlrewrite.xml that was created.

For my purposes, I was migrating from dokuwiki to Confluence. My old doc site running on dokuwiki was docs.mydomain.com but I wanted to move it to archives.mydomain.com and use the docs.mydomain.com URL for my new Confluence site.

For special characters like “.” or “:” or “?” I had to use a back slash (“”) in front of the special character — see below for an example.

Here is my urlrewrite.xml file

<?xml version=”1.0″ encoding=”utf-8″?>

<!DOCTYPE urlrewrite PUBLIC “-//tuckey.org//DTD UrlRewrite 2.6//EN” “http://tuckey.org/res/dtds/urlrewrite2.6.dtd“>

<urlrewrite>
<rule>

<from>^/ecf/5.1/doku.php?id=getting_started$</from>
<to type=”redirect”>/display/ecf51releasehistory/Home</to>

</rule>

<rule>
<from>^/ecf/5.1/doku.php?id=configuration_and_deployment:installation_guide:prerequisites$</from>
<to type=”redirect”>/display/ecf51installanddeploy/System+Requirements</to>
</rule>

<rule>
<from>^/ecf/5.1/doku.php?id=configuration_and_deployment:installation_guide:mediachase_wizard_installation$</from>
<to type=”redirect”>/display/ecf51installanddeploy/SDK+Installation+Using+Installer</to>
</rule>

<rule>
<from>^/ecf/5.1/doku.php?id=configuration_and_deployment:installation_guide:mediachase_wizard_installation#verificationperforming_simple_end_user_tasks$</from>
<to type=”redirect”>/display/ecf51releasehistory/Home</to>
</rule>

<rule>
<from>^/ecf/5.1</from>
<to type=”redirect”>/dashboard.action</to>
</rule>

<!– For image references in CSS files –>
<rule>
<from>^/s/(.*)/_/download/images/([^?]*).*</from>
<run method=”addPublicCachingHeaders” />
<to type=”forward”>/images/$2</to>
</rule>

<rule>
<from>^/s/(.*)/_/([^?]*).*</from>
<run method=”addPublicCachingHeaders” />
<to type=”forward”>/$2</to>
</rule>

</urlrewrite>

5) Restart the Apache Tomcat Confluence service.

Leave a Reply

Your email address will not be published. Required fields are marked *