Shortening the context root of a remote store URL

Stores that are running on the dedicated store container (crs-app) are often referred to as remote stores. You can shorten the context root of your store's URL to make it easier for shoppers to remember a link. Shorting the context root also improves visibility in search engine results.

About this task

You can shorten the URL for your store by modifying the context root. You can change the default site URL from http://hostname/wcs/shop/servlet/StoreName/index.jsp to something shorter, such as: http://hostname/my_shop/index.jsp, as seen in the following example.

The following procedure modifies the context root, but does not remove it.

Important: If there is an invalid protocol or timeout with a redirect, the redirected URL uses the full path, rather than the URL with the shortened context root.

Procedure

  1. Update the context-root value in your application.xml file.
    1. Open the following file for editing.
      • HCL Commerce Developerworkspace_dir\crs\META-INF\application.xml
      • /opt/WebSphere/Liberty/usr/servers/default/apps/crs.ear/META-INF/application.xml
    2. Locate the following module.
      <module>
          <web>
            <web-uri>crs-web.war</web-uri>
            <context-root>/wcs</context-root>
          </web>
        </module>
      
    3. Update the context-root value to a value of your choice. For example, /.
      The following example illustrated the updated code.
      <module>
          <web>
            <web-uri>crs-web.war</web-uri>
            <context-root>/</context-root>
          </web>
        </module>
      
    4. Save and close the file.
  2. Update your wc-store.xml file.
    1. Open the following file for editing.
      • HCL Commerce Developerworkspace_dir\crs\xml\config\wc-store.xml
      • /opt/WebSphere/Liberty/usr/servers/default/apps/crs.ear/xml/config/wc-store.xml
    2. Locate the following web module.
      <WebModule>
          <Module contextPath="/wcs"
            name="Stores"
            urlMappingPath="/shop" webAlias="/wcsstore">
      
    3. Update the contextPath and the urlMappingPath to values of your choice.
      The following example illustrates the updated code.
      <WebModule>
          <Module contextPath="/"
            name="Stores"
            urlMappingPath="/my_shop" webAlias="/wcsstore">
      
    4. Save and close the file.
  3. Update your web.xml file.
    1. Open the following file for editing.
      • HCL Commerce Developerworkspace_dir\crs-web\WebContent\WEB-INF\web.xml
      • /opt/WebSphere/Liberty/usr/servers/default/apps/crs.ear/crs-web.war/WEB-INF/web.xml
    2. Locate the following servlet-mapping.
      <servlet-mapping>
          <servlet-name>Stores</servlet-name>
          <url-pattern>/shop/*</url-pattern>
      </servlet-mapping>
      
    3. Update the url-pattern for the Store servlet to a value of your choice.
      The following example illustrates the updated code.
      <servlet-mapping>
          <servlet-name>Stores</servlet-name>
          <url-pattern>/my_shop/*</url-pattern>
      </servlet-mapping>
      
    4. Save and close the file.
  4. Update your foundation component.xml file.
    1. Open the following file for editing.
      • HCL Commerce Developerworkspace_dir\WC\xml\config\com.ibm.commerce.foundation\wc-component.xml
      • /opt/WebSphere/AppServer/profiles/default/installedApps/localhost/ts.ear/xml/config/com.ibm.commerce.foundation/wc-component.xml
    2. Locate the following property.
      <!-- value to remote store context root -->
      <_config:property name="wc.store.remote.webContextPath" value="/wcs/shop"/>
      
    3. Update the property value for the wc.store.remote.webContextPath to a value of your choice.
      The following example illustrates the updated code.
      <!-- value to remote store context root -->
      <_config:property name="wc.store.remote.webContextPath" value="/my_shop"/>
      
    4. Save and close the file.
  5. If your site uses the crs-alias-proxy-web.war to forward static assets with the /wcsstore context to the crs-web.war, then you must update your crs-alias-proxy-web.war/web.xml file with the correct TargetContextRoot value. Otherwise, the static assets that are located in your crs -web.war cannot be accessed from the /wcsstore path.
    Note: If your context crs-web.war root is /, then you can skip this step because this context root can be automatically found. You can also skip this step if your site does not use crs-alias-proxy-web.war to forward static assets to crs-web.war; for example, you use a web server or content server to handle static assets with the /wcsstore path.
    1. Open the following file for editing.
      • HCL Commerce Developerworkspace_dir\crs-alias-proxy-web\WebContent\WEB-INF\web.xml
      • /opt/WebSphere/Liberty/usr/servers/default/apps/crs.ear/crs-alias-proxy-web.war/WEB-INF/web.xml
    2. Locate the TargetContextRoot setting, and update the value to match your new context root.
    3. Save and close the file.
  6. Restart your remote store server.