Skip to content

URL Rewrites

SWS provides the ability to rewrite request URLs with pattern matching support.

URI rewrites are particularly useful with pattern matching (globs), as the server can accept any URL that matches the pattern and let the client-side code decide what to display.


The URL rewrite rules should be defined mainly as an Array of Tables.

Each table entry should have two key/value pairs:

  • One source key containing a string glob pattern.
  • One destination string containing the local file path.


The incoming request(s) will reach the destination only if the request(s) URI matches the source pattern.


The source is a Glob pattern that should match against the URI that is requesting a resource file.


A local file path which must exist. It has to look something like /some/directory/file.html. It is worth noting that the / at the beginning indicates the server's root directory.



### URL Rewrites

source = "**/*.{png,ico,gif}"
destination = "/assets/generic1.png"

source = "**/*.{jpg,jpeg}"
destination = "/images/generic2.png"

Last update: 2022-07-06