Redirection to another confluence base url

Pangianto Pang August 23, 2012

Hi All,

I have migrated the one server (http://server_old) confluence to the other server (http://server_new), now i am required to do redirection to the new server when people type in the old server confluence address with any page

example case: http://server_old/any_space/any_page => http://server_new/any_space/any_page)

May i know is there anyway to do this?

Thanks in advanced.

3 answers

0 votes
iLevel March 18, 2014

Stumbled across this in a Google search...not sure if it's been answered already elsewhere, but I figured I'd offer what I used to fix it (mostly).

Confluence (at least in v5.3.1) comes with a jar called URLRewrite, which the Confluence server uses for its own purpose. Using that plugin, some DNS wizardry, and the instructions here: http://tuckey.org/urlrewrite/it's possible to set up a redirect so that when someone requests server_old, they hit your new server's Tomcat server though the DNS entry, their URL is rewritten, and the url that shows up is server_new.

The word "mostly" is because while this works well for people who visit the root of the Confluence page, I'm still working out the scenario where the user had a full link (short or long) as the links are being redirected to the home page right now. Since I'm mostly Windows/IIS, this Tomcat stuff isn't so natural, so perhaps there's a way to adjust Tomcat's redirect rules to that end. I'm still hacking away at it, but if I find out what the fix is on that, I'll reply appropriately.

iLevel March 20, 2014

To follow-up, here's what we ended up doing that worked.

1) In the %install_dir%\confluence\Web-Inf\web.xml file - put the following as the first filter in the list of filters

<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>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>

2) In the %install_dir%\confluence\Web-Inf\urlrewrite.xml file, add the following at the bottom of the doc, right before the </urlrewrite> tag:

<rule>
<condition name="host" operator="notequal">^server_new</condition>
<condition name="host" operator="notequal">^localhost</condition>
<condition type="port" operator="equal">port Tomcat server is running on</condition>
<from>^/(.*)</from>
<to type="permanent-redirect" last="true">http://server_new/$1</to>
</rule>

If you are running Confluence over SSL, then you will need two of the above rules, one for each port Tomcat has open (defaults of 8090 and 8443). The $1 is extremely important; without it, tiny links with server_old as the server will redirect to the root of the Confluence instance instead of the desired page.

0 votes
Pangianto Pang August 23, 2012

I am running on Tomcat, can teach how to do the redirection using Tomcat? any useful link?

Thanks Nic.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 23, 2012

Not in the application, but there's options.

If you're running it behind something like Apache, then that can easily do rewrites or redirects.

You could do it with network config too, simply mapping DNS so that the old server name resolves to the new one.

The Tomcat running Confluence might be capable of redirecting too, although I'm not sure (and I don't know that you're actually on Tomcat either - look for the docs on whatever application server you are running)

As a last option, write a short web-application that replaces Confluence and redirects if users land on it.

Pangianto Pang August 23, 2012

I am running on Tomcat, can teach how to do the redirection using Tomcat? any useful link?

Thanks Nic.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 23, 2012

I'm out of my depth I'm afraid - I've nearly always used the DNS method. I've done a couple of Apache tricks and seen a Tomcat app written to redirect certain urls once.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events