Friday, 30 March 2018

Empty Context root implementation - For Shortening the context root of a store URL in WebSphere Commerce 8

Shortening the context root of a store's URL makes it easier for shoppers to remember a link and also improves visibility in search engine results in WebSphere Commerce 8.


Step-by-Step Process

STEP 1: Modify contex root on IBM HTTPServer 

1. Go to WC_installdir/instances/instanceName/httpconf
2. Open httpd.conf
3. Uncommented the following line
LoadModule rewrite_module modules/mod_rewrite.so
4. Locate the virtualhost object: <VirtualHost servername:80> OR <VirtualHost *:80>
5. Insert the following code inside the <VirtualHost servername:80>
RewriteEngine on 
RewriteRule ^/(?!wcsstore)(.*) /webapp/wcs/stores/servlet/$1 [PT,L]
Note: 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.

6. Repeat the preceding step for any other virtual host that your environment uses. For example, <VirtualHost servername:443> or <VirutalHost *:8006>.
7. Save the file & Restart IBM HTTPServer

STEP 2: update the WebSphere Commerce server configuration file to provide the context root rewrite rule value:

1. Open WebSphere Commerce server Master configuration file (WC_Server.xml)
File Location: WC_installdir /instances/instance_name/xml/instance_name.xml
2. Search for the SEOConfiguration section, And Enter the following code
<context-root-rewrite value="/" />
For example:
<SEOConfiguration defaultUrl="" dynamicUrl="true" enable="true">
<context-root-rewrite value="/" />
</SEOConfiguration> 
3. Save the file and Propagate the changes to WebSphere Commerce Server EAR file
Run this command /opt/IBM/WebSphere/CommerceServer80/bin/config_ant.sh -DinstanceName=instance_name UpdateEAR
OutPut: BUILD SUCCESSFUL. This process can take some time to complete.
4. Restart the servers.
All the best..!

1 comment: