Thanks. I'm on 1.95 and this is working very nicely.


On 28 June 2013 09:15, Christopher Faulet <> wrote:
On 28/06/2013 00:13, JD Bothma wrote:
> Is this kind of thing considered supported use of #sconf{} in yaws embedded?
> redirect_map = [{"/p/b", #url{host=" <>",path="/"},
> noappend}
> I basically want a list of redirects to a different site and they're
> quite irregular so writing an appmod feels silly when yaws would support
> this easily in a config file (and with a glance at the sconf record
> definition :)


Yes, you can setup redirect_map when Yaws is embedded. The redirect
syntax has changed in Yaws 1.96. Now, you can set the HTTP status code
used in redirect rules (302 by default). So the format for the
redirect_map list in #sconf{} is:

 [{Path, HTTPCode, UrlOrPath, Mode}]  where

    Path      := string()  %% a relative path
    HTTPCode  := integer() %% between 100 and 599
    UrlOrPath := #url{} | Path | undefined
    Mode      := append | noappend

For 3xx status codes, UrlOrPath must be a #url{}. For other status
codes, it must be a relative path or undefined. Here is an example:

  RMap = [{"/p/b", 302, #url{host="",path="/"}, noappend}].
  SL   = [{listen, ""}, {port, 8000}, {redirect_map, RMap}].
  yaws_api:embedded_start_conf("/tmp", SL).

See yaws.conf manpage for details about redirect mapping.

This email is sponsored by Windows:

Build for Windows Store.
Erlyaws-list mailing list