Enable URL rewriting
-
Go to
<DATADIR>/webapps/360-mashup-ui/WEB-INF/
-
Edit the
WEB-INF/web.xml file.
-
Uncomment the
UrlRewriteFilter filter node.
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>log4j</param-value>
</init-param>
<init-param>
<param-name>confReloadCheckInterval</param-name>
<param-value>5</param-value>
</init-param>
<init-param>
<param-name>statusEnabled</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-
Save and close the file.
Configure URL rewriting
-
In the
<DATADIR>/webapps/360-mashup-ui/WEB-INF/ directory, edit the WEB-INF/urlrewrite.xml file.
-
Uncomment the content of the
urlrewrite node, and add/edit the rewriting rules as needed. For our example of /products/clothes/shirt we would have the following configuration.
<urlrewrite>
<!-- Services have the highest priority -->
<rule enabled="true">
<name>Services</name>
<from>^/(resources|fetch|alerting|export|utils|login|errors|lang|storage|logout
|staging-builder|testProduction)(.*)?</from>
<to last="true">/$1$2</to>
</rule>
<!-- redirects /page/index to / -->
<rule enabled="true">
<name>RedirectIndex</name>
<from>^/page/index$</from>
<to last="true" type="redirect">%{context-path}/?%{query-string}</to>
</rule>
<!-- redirects /page/pageName to /pageName -->
<rule enabled="true">
<name>RedirectPages</name>
<from>^/page/(\w+)$</from>
<to last="true" type="redirect">%{context-path}/$1?%{query-string}</to>
</rule>
<!-- / -->
<rule enabled="true">
<name>Index</name>
<from>^/$</from>
<to last="true">/page/index</to>
</rule>
<!-- /pageName -->
<rule enabled="true">
<name>Pages</name>
<from>^/(\w+)$</from>
<to last="true">/page/$1</to>
</rule>
<!-- /products/clothes/shirt -->
<rule enabled="true">
<name>Search</name>
<from>^/(\w+)/(\w+)/(\w+)</from>
<to>/page/search?type=$1&$2=$3</to>
</rule>
</urlrewrite>
Note that:
- First, all the services that can be called by the Mashup UI (export, alerting, storage, etc.) are processed. We make sure they will not be impacted by URL rewriting to avoid errors. We can then add filter rules for the URLs of the application pages.
-
/page/ is hidden from the URL
- The
/ redirects to the index page
-
Save and close the file.
|