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
- Update the
context-root
value in your
application.xml file.
- Open the following file for editing.
- workspace_dir\crs\META-INF\application.xml
- /opt/WebSphere/Liberty/usr/servers/default/apps/crs.ear/META-INF/application.xml
- Locate the following module.
<module>
<web>
<web-uri>crs-web.war</web-uri>
<context-root>/wcs</context-root>
</web>
</module>
- 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>
- Save and close the file.
- Update your wc-store.xml file.
- Open the following file for editing.
- workspace_dir\crs\xml\config\wc-store.xml
- /opt/WebSphere/Liberty/usr/servers/default/apps/crs.ear/xml/config/wc-store.xml
- Locate the following web module.
<WebModule>
<Module contextPath="/wcs"
name="Stores"
urlMappingPath="/shop" webAlias="/wcsstore">
- 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">
- Save and close the file.
- Update your web.xml file.
- Open the following file for editing.
- workspace_dir\crs-web\WebContent\WEB-INF\web.xml
- /opt/WebSphere/Liberty/usr/servers/default/apps/crs.ear/crs-web.war/WEB-INF/web.xml
- Locate the following servlet-mapping.
<servlet-mapping>
<servlet-name>Stores</servlet-name>
<url-pattern>/shop/*</url-pattern>
</servlet-mapping>
- 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>
- Save and close the file.
- Update your foundation component.xml file.
- Open the following file for editing.
- workspace_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
- Locate the following property.
<!-- value to remote store context root -->
<_config:property name="wc.store.remote.webContextPath" value="/wcs/shop"/>
- 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"/>
- Save and close the file.
- 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.
- Open the following file for editing.
- workspace_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
- Locate the
TargetContextRoot
setting, and update the value to match
your new context root.
- Save and close the file.
- Restart your remote store server.