Use friendly URLs without state information
Overview
By default, WebSphere Portal URLs include navigational state information. If we configure pages for friendly URLs, the portal appends the state information to the friendly URLs. Some scenarios require short and fully human readable URLs that omit the state information. For such scenarios we can configure friendly URLs so that the portal does not show that state information.
The state information is an encoded aggregation of the navigational state of the portal, the page and its components, for example, the portlets on the current page:
- Portal state includes page selection, expansions, label mapping, and action targets.
- Portlet state includes render parameters, window state, and portlet mode.
The representation of the navigational state within the URL enables characteristics of dynamic web sites, such as usage of bookmarks or the Back button. For example, users can bookmark a page and later return to the exact same state on that page.
Some scenarios require short and fully human readable URLs that omit the state information. Examples:
- You do not want the URL to make the impression that it references dynamic content.
- You want the URL to contain only information that a human person can read and interpret.
- You want the URL to easily fit into the address field of the web browser.
- Internet search engines expect static URLs that reference only one web page for as long as this page exists
- Internet search engines prefer short and friendly URLs.
For such scenarios you configure WebSphere Portal as follows:
- Configure themes to always display only short friendly URLs without the encoded navigational state.
- Configure pages that use that theme to display friendly URLs.
The configuration applies to all pages that use that theme and that are configured to display friendly URLs.
If we configure the portal to show only stateless friendly URLs, the URLs always point to the default state of a page, as they do not contain the state information.
Configure stateless friendly URLs
- Log on to the WAS admin console, and in the WP ConfigurationService, set...
custom parameter friendly.redirect.enabled = false
- In the theme to configure for short stateless URLs, set...
com.ibm.portal.theme.hasBaseURL = true
We can update the theme parameter using xmlaccess.sh.
- Make sure that all generated URLs in the theme do not include the navigational state.
In the default Portal 8.0 theme, we can do this by modifying the file navigation.jsp. By default, this JSP file includes the following code snippet:
<li class="wpthemeNavListItem wpthemeLeft<c:if test="${wp.selectionModel[node] != null}">wpthemeSelected</c:if>"> <a href="http://setgetweb.com/p/portal80/?uri=nm:oid:${nodeID}" class="wpthemeLeft<c:if test="${childrenStatus.count == 1}">wpthemeFirst</c:if>" <c:if test="${primeNode}">data-nm-level="${level+1}" data-nm-primed="<portal-fmt:out> <portal-core:navigationNodePriming navigationNode="${nodeID}" metaData="${navHiddenMetadata}" considerChildren="false" includeRoles="true" /> </portal-fmt:out>"</c:if>> <span lang="${node.title.xmlLocale}" dir="${node.title.direction}"> <c:choose><c:when test="${node.projectID != null}">(<c:out value="${node.title}"/>) </c:when><c:otherwise><c:out value="${node.title}"/></c:otherwise></c:choose> <c:if test="${selectedNodeID == nodeID}"> <span class="wpthemeAccess"> <portal-fmt:text key="currently_selected" bundle="nls8.Theme"/> </span></c:if> </span></a> <portal-dynamicui:closePage node="${node}"> <a class="wpthemeClose wpthemeLeft" href="http://setgetweb.com/p/portal80/<%closePageURL.write(out);%>"> <img src="${themeConfig['resources.modules.ibm.contextRoot']}/themes/html/NavigationClose.gif"> </a> </portal-dynamicui:closePage>To generate stateless URLs, replace the middle section of this code snippet in navigation.jsp by the update shown in the following snippet:<li class="wpthemeNavListItem wpthemeLeft<c:if test="${wp.selectionModel[node] != null}"> wpthemeSelected</c:if>"> <portal-navigation:urlGeneration contentNode="${nodeID}" keepNavigationalState="false"> <a href="http://setgetweb.com/p/portal80/<%wpsURL.write(out);%>" class="wpthemeLeft<c:if test="${childrenStatus.count == 1}">wpthemeFirst"</c:if>" <c:if test="${primeNode}">data-nm-level="${level+1}" data-nm-primed="<portal-fmt:out> <portal-core:navigationNodePriming navigationNode="${nodeID}" metaData="${navHiddenMetadata}" considerChildren="false" includeRoles="true" /> </portal-fmt:out>"</c:if>> <span lang="${node.title.xmlLocale}" dir="${node.title.direction}"> <c:choose><c:when test="${node.projectID != null}">(<c:out value="${node.title}"/>) </c:when><c:otherwise><c:out value="${node.title}"/></c:otherwise> </c:choose><c:if test="${selectedNodeID == nodeID}"> <span class="wpthemeAccess"> <portal-fmt:text key="currently_selected" bundle="nls8.Theme"/> </span></c:if> </span></a> </portal-navigation:urlGeneration> <portal-dynamicui:closePage node="${node}"> <a class="wpthemeClose wpthemeLeft" href="http://setgetweb.com/p/portal80/<%closePageURL.write(out);%>"> <img src="${themeConfig['resources.modules.ibm.contextRoot']}/themes/html/NavigationClose.gif"> </a> </portal-dynamicui:closePage>
- Optional: For IBM Web Content Manager: If you want the IBM Web Content Manager Rendering portlet to also display the friendly and stateless URLs, implement a plug-is that translates the IBM Web Content Manager URLs into the required custom format. For instructions and sample code for such a plug-in see Example 2: Generate a friendly URL for web content in the IBM Web Content Manager documentation.
- Set friendly URL names for pages as required. For information about how to do this see Use friendly URLs.
The portal now no longer displays the state information with the URLs.
Parent: Use friendly URLs
Related:
Portal configuration services
Set service configuration properties
Related:Web Content Manager - Example 2: Generate a friendly URL for web content