Skip to content

URL Redirects

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

URI redirects are particularly useful with pattern matching (globs). Use them for example to prevent broken links if you've moved a page or to shorten URLs.


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

Each table entry should have the following key/value pairs:

  • One source key containing a string glob pattern.
  • One destination string containing the local file path or a full URL.
  • One kind number containing the HTTP response code.


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 must exist. It can be a local path /some/directory/file.html or a full URL. It is worth noting that the / at the beginning indicates the server's root directory.


It indicates the HTTP response code. The values can be:

  • 301 for "Moved Permanently"
  • 302 for "Found" (Temporary Redirect)



### URL Redirects

source = "**/*.{jpg,jpeg}"
destination = "/images/generic1.png"
kind = 301

source = "/index.html"
destination = ""
kind = 302

Last update: 2023-03-27