When you migrate your store from a previous version of HCL Commerce to version 9.0,
your store runs on the transaction server (trs-app
) and is often referred to as a
local store. In addition to running on the transaction server, your local store also uses the
transaction web server (trs-web
). If you are using a local store, 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/shop/StoreName/index.jsp. In this
example, shop
is used to replace the context root, but any name can be used in its
place, including a blank context root value.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
To modify the context root in IBM HTTP Server:
-
Go to your Docker Web container by running docker exec -it bvt_web_1 bash,
then change to the /SETUP/config directory.
-
Open httpd.conf file for editing.
-
Ensure that the following line is not commented out:
LoadModule rewrite_module modules/mod_rewrite.so
-
Locate the
virtualhost
object: <VirtualHost
servername:80>
. This object can display as <VirtualHost *:80>
-
Insert the following code inside the
<VirtualHost servername:80>
object
before the ending </VirtualHost>
tag.
RewriteEngine on
RewriteRule ^/shop/(.*) /wcs/shop/servlet/$1 [PT,L]
If you are specifying a blank context root, use the following format
instead:
RewriteEngine on
RewriteRule ^/(?!wcsstore)(.*) /wcs/shop/servlet/$1 [PT,L]
Using
the preceding format when you are specifying a blank context root ensures that the storefront
continues to function correctly. Otherwise, you might encounter errors with storefront CSS and
images not displaying correctly.
-
Repeat the preceding step for any other virtual host that your environment uses.
For example, <VirtualHost servername:443>
or <VirutalHost
*:8006>
.
-
Save the file.
-
Restart the IBM HTTP server.
What to do next
Once the rewrite rule is updated in the web server, update
the Transaction server configuration file to provide the context
root rewrite rule value:
- Open the remote store configuration file, which is located in the following
directory.
/opt/WebSphere/AppServer/profiles/default/installedApps/localhost/ts.ear/xml/config/wc-server.xml
- Search for the
SEOConfiguration
section.
- Within the
SEOConfiguration
section, enter the
following code: <context-root-rewrite value="/shop" />
For
example: <SEOConfiguration defaultUrl="" dynamicUrl="true" enable="true">
<context-root-rewrite value="/shop" />
</SEOConfiguration>
- Save the file.