-module(cl7_urlrewrite). -export([arg_rewrite/1]). -include_lib("yaws/include/yaws_api.hrl"). arg_rewrite(Arg) -> Req = Arg#arg.req, {abs_path, Path} = Req#http_request.path, NPath = {abs_path, case string:rstr(Path, ".html") of 0 -> Path; N -> "/?page=" ++ string:substr(Path, 2, N - 2) ++ string:substr(Path, N + 5) end }, % pour les tests %{ok, F} = file:open("/tmp/out.txt", [write]), %io:format(F, "~p~n", [Path]), %file:close(F), Arg#arg{req = Req#http_request{path = NPath}}.