Skip to main content

URL Shortener

  • create a generic list e.g. short-urls https://qsc.quasiris.de/console/list/playground with type short-urls
  • configure columns:
    • shortUrl - string
    • url - string
    • redirectCode - string or long
    • type
      • default - default - if no type is defined
      • replace - replace the parameter like path, query
  • add a new row
  • wait 5 minutes, because of caching
  • curl -i https://qsc.quasiris.de/api/v1/short-url/playground/short-urls/my-short-url-documentation

Replace

With the type replace it is possible to create the Location url dynamically. Parameters from the source url can be replaced in the Location url.

Example: In this example we replace we use the path search and the q query parameter from the Reqeust url.

Request url: https://qsc.quasiris.de/api/v1/short-url/playground/short-urls/my-short-url-documentation/search?page=0&q=my+query

Configured url:q https://my-domain.com/${path0}?query=${q}

Location: https://my-domain.com/search?query=my+query

Paramters:

ParameterExampleComment
shortUrlmy-short-url-documentationthe short url from the path
tenantplaygroundthe tenant code
codeshort-urlsthe code of the list
queryStringpage=0&q=my+querythe complete queryString
query.page0the value for the query parameter page
query.qmy+querythe value for the query parameter q
path0searchthe first path part after the shortUrl
pathAfterShortUrlsearchthe whole path after the short url

Limitations:

  • multiple values for a query parameter are not supported. Just the first value is used

Rewrite with nginx

To use the short url's i a convenient way, a nginx rewrite can be used.

location /s/ {
rewrite ^/s/(.*)$ /api/v1/short-url/playground/short-urls/$1 last;
}

The url https://my-domain.com/s/my-short-url-documentation is internally rewrited to http://qsc.quasiris.de/api/v1/short-url/playground/short-urls/my-short-url-documentation