Adding a URL rewrite to AppWorks Gateway 16.x

Clayton_Edmund
edited July 19, 2021 in Articles #1

originally posted April 11, 2019 | 🕐️ 2 minute read

When upgrading from AppWorks Gateway 1.2.x to 16.x, you may want your users to access your configured services via the same URL as before. This article describes how to use URL rewriting to achieve this.

In AppWorks Gateway 16.x both the Gateway and the Administration Console are accessed via the root context of the Apache Tomcat installation.

This is a change from AppWorks Gateway 1.2.x, where users were taken to /webaccess from https://[appworksurl]/, from where they could access the services that were configured there, for example, Tempo Box or Tempo Social.

When upgrading to 16.x, you may want to ensure that users continue to access any configured services with the URL they used prior to the upgrade.

To do this, you can use URL rewriting to perform a URL redirect to the /content folder.

The following steps describe how to redirect your users from http://host.opentext.com to http://host.opentext.com/content by downloading and configuring a Java Web filter for the Apache Tomcat installation.

  1. Stop the Apache Tomcat service.
  2. Go to the UrlRewriteFilter web site.
  3. Click the urlrewritefilter-4.0.3.jar link in Step 1 of the Install process. To review the documentation for the Web Filter, click Documentation at the top of the page, then click the link to the 4.0 User Manual.
  4. Save the .jar file to <Tomcat_Home>/gateway/WEB-INF/lib.
  5. Add the following to the <Tomcat_Home>/gateway/WEB-INF/lib/web.xml file:
<filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
    <async-supported>true</async-supported>
</filter>
<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
       <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

📘 Note: The UrlRewriteFilter must be the first filter in the web.xml file.

6. Create a urlrewrite.xml file in <Tomcat_Home>/gateway/WEB-INF/, with the following contents:

<urlrewrite>
<rule>
    <name>redirect from root</name>
    <condition name="host" operator="equal">host.opentext.com</condition>
    <from>^/$</from>
    <to type="permanent-redirect" last="true">http://host.opentext.com/content/</to>
</rule> </urlrewrite>

7. Start the Apache Tomcat service.

📘 Note: This configuration will redirect from http://host.opentext.com to http://host.opentext.com/content, which will mask the Gateway Administration Console. To access the console, the host's IP address, or some other alias must be entered into the browser address bar.