This blog promotes knowledge sharing through experience and collaboration. For more product information, visit our WebSphere Commerce CSE page. For easier navigation, utilize the Categories to find posts that match your interest.
Modifying Context Root in Commerce v9
In Commerce v7 and Commerce v8, modifying the store context root was a relatively simple change to the httpd.conf, which we document in the Knowledge Center. However, in Commerce v9, this has changed significantly, due to store separation. Since the store runs on Liberty in it's own Docker container (crs-app), we no longer have a web server in front of store requests, so there is no httpd.conf to modify anymore.
By default in Commerce v9, we use /wcs/shop/ as the context root for store URLs. You will need to follow one of the following two procedures depending on the scenario you're trying to achieve.
Remove Context Root Entirely
If you want to remove the context root entirely, such that /wcs/shop/ turns into /, this is not currently possible unless you setup a web server in front of the store container (crs-app) to accept requests and use RewriteRules to modify the URL. This would essentially follow same process as you would do for Commerce v7 and Commerce v8, except you would make these RewriteRule changes to the httpd.conf for the web server for crs-app, which you could then consider containerizing as crs-web.
Shorten/Modify Context Root
For example, say you want to modify the context root such that /wcs/shop/ turns into /mystore/, you can do this without needing to setup a separate web server for the store server. To make this change, you'll need to change the context root tokens, such that:
These context root tokens are hardcoded in the following files:
These changes can easily be modified through setting up a Dockerfile to create customized versions of the OOTB images. Below are the sample Dockerfiles I'm using to create customized versions of the OOTB images to turn /wcs/shop/ into /mystore/:
You can run docker build on these Dockerfiles to create new images with these changes made on top of the OOTB images. Once the customized images have been build, update your Docker container startup process (docker run, docker-compose, etc) to reference the customized images and then startup your customized images. Now you can make requests to the storefront using the new context root:
Feel free to post in the comments below if you have an interesting URL context root rewrite scenario and how you're getting the same changes to work for your Commerce v9 environment.