Deconstructing an SEO-friendly URL
When a shopper clicks on a link for a page in the store, they see an SEO-friendly URL. HCL Commerce can process the embedded category, store name, language, and product information only if this SEO-friendly URL is translated to the standard URL format. To translate the SEO-friendly URL to the standard URL, use SEOURL, SEOURLKEYWORD, and SEOTOKENUSGTYPE, and a URL pattern definition file.
Translating an SEO-friendly URL to a traditional URL:
This example describes how the system constructs the SEO-friendly URL for the coffee-makers category, http://myhost.com/shop/en/aurora/coffee-makers. It describes how HCL Commerce converts the URL back to its original URL format so that it can be processed.
- The web server receives the link http://myhost/shop/en/aurora/coffee-makers, replaces shop with the context root: http://myhost/wcs/shop/en/aurora/coffee-makers. The web server sends a request to the HCL Commerce server for further processing.
- When the HCL Commerce server receives the URL, it removes the context root and then processes the remaining information. The rest of the information is divided into keywords (en/aurora/coffee-makers) by using the slash (/) as a separator to retrieve en, aurora and coffee-makers.
- The keywords are used for two purposes in translating a URL: to determine the URL pattern, which
indicates the kind of URL construction, and to obtain the necessary values
to build the original URL.
Sample URL types: URL type Pattern Sample non-SEO URL Catalog LanguageToken/StoreToken:CatalogToken ...TopCategoriesDisplay?langId=-1&storeId=10001&catalogId=10002 Category LanguageToken/StoreToken:CatalogToken/CategoryToken ...CategoryDisplay?langId=-1&storeId=10001&catalogId=10002&categoryId=10003 Product LanguageToken/StoreToken:CatalogToken/CategoryToken/ProductToken ...ProductDisplay?langId=-1&storeId=10001&catalogId=10002&categoryId=10003&productId=10004 Contact Us LanguageToken/StoreToken:CatalogToken/ContactToken ...HelpContactUsView?langId=-1&storeId=10001&catalogId=10002 - Determining the URL pattern and values:
- The keywords are translated into tokens. The keywords are stored in multiple places, depending
on the keyword type. Language keywords are stored in the language registry which pulls contents from
the LANGUAGE table, while other keywords are stored in the SEOURLKEYWORD table:
- en is found in the language registry. Because only languages are stored here, this determines that its token is LanguageToken. The value for en is -1.
- aurora is found in the SEOURLKEYWORD table, where it is listed as a combination
of a StoreToken and a CatalogToken, for example
StoreToken:CatalogToken
with values of 10001 and 10002 respectively and represented as 10001:10002. - coffee-makers is found in the same table, where it is listed as a CategoryToken with a value of 10003.
- With these tokens, the pattern is LanguageToken/StoreToken:CatalogToken/CategoryToken. To determine the type of URL that is being deconstructed, the system finds the correct pattern in the pattern file(s). Pattern files contain patterns for every type of web page in the store, such as category, department, product, help, or other page.
- The keywords are translated into tokens. The keywords are stored in multiple places, depending
on the keyword type. Language keywords are stored in the language registry which pulls contents from
the LANGUAGE table, while other keywords are stored in the SEOURLKEYWORD table:
- The viewName attribute of this pattern indicates that the SEO-friendly URL is actually a
CategoryDisplay struts action. Using the information found in the section named urlToParamMapping,
the parameters are extracted from the SEOURLKEYWORD
table:
The values for each parameter is extracted from looking in the SEOURL and SEOURLKEYWORD tables and language registry contents:<seourl:urlToParamMapping> <seourl:mapping name="langId" value="?LanguageToken?" /> <seourl:mapping name="storeId" value="?StoreToken?" /> <seourl:mapping name="catalogId" value="?CatalogToken?" /> <seourl:mapping name="categoryId" value="?CategoryToken?" /> </seourl:urlToParamMapping>
- For the language, langId = LanguageToken which is -1
- For the store, storeId = StoreToken which is 10001
- For the catalog, catalogId = CatalogToken which is 10002
- For the category, categoryId = CategoryToken which is 10003
A sample combination of SEOURL and SEOURLKEYWORD tables and language registry contents. This table is for illustration purposes only: Keyword Token Name Token Value aurora StoreToken:CatalogToken 10001 (storeId value):10002 (catalogId value) coffee-makers CategoryToken 10003 (categoryId value) en LanguageToken -1 (langId value) - With the information found in the SEOURLKEYWORD table, the non SEO-friendly URL is constructed
in the formatting found in the pattern file
(LanguageToken/StoreToken:CatalogToken/CategoryToken):
http://myhost.com/shop/CategoryDisplay?langId=-1&storeId=10001&catalogId=10002&categoryId=10003
WebSphere Commerce server executes the view with the specified parameters and sends the result to the browser.