• Entries (RSS)
  • Comments (RSS)

How to create vanity url for HANA services

Posted by | Posted in HANA | Posted on 10-02-2014

Tagged Under : ,

How to create vanity url for HANA services using URL Rewriting

SAP HANA provides an option to create an alias or vanity URL for services created in HANA. This will help HANA developers not to expose the internal service path to the external service users. It also helps the developers to keep the url intact even when the internal service implementation has changed. Developers can write URL rewrite rules using JavaScript regex syntax inside the HANA Application access file (.xsaccess) to provide the alias for a service. The rewrite rules are specified as source and target values. The source can be a JavaScript regex. Follow the below steps to rewrite your urls in SAP HANA.

The source service url you have is http://server:port/services/com/example/path/salesOrders.xsjs?salesOrderNumber=1234 and you want to access the service using a different url like http://server:port/services/salesorders/1234/. The first step in creating a vanity url like the above is to create an .xsaccess file inside your services directory in SAP HANA studio. The contents of the .xsaccess file will be like the following

	"rewrite_rules" : 
				"source": "/salesorders/(\\d*)/", 
				"target": "/com/example/path/salesOrders.xsjs?salesOrderNumber=$1"

In the above example $1 will be replaced by the value entered by the user(1234). If you have more than one input to accept, you can use $2, $3 etc to get the user input.