Rewrite module

klacke edited this page Sep 13, 2010 · 1 revision

arg_rewrite_mod = rewriter

between the virtual server definition in the yaws.conf file.

For example:

<server localhost>
  port = 8080
  listen =
  docroot = /var/www/yaws-default
  arg_rewrite_mod = rewriter

Below is an example/template of how I managed to get something working. I’m not sure if this is the ‘right’ way to do it however.. Feel free to comment & improve/replace it.





arg_rewrite(ARG) ->
        Req = ARG#arg.req,
        case Req#http_request.path of
        {abs_path, RawPath} ->
		case (catch yaws_api:url_decode_q_split(RawPath)) of
		{'EXIT', _} -> %%broken request - ignore let yaws_server handle it.
			ARG2 = ARG;
		{DecPath, QueryPart} ->
		 	Parts = string:tokens(DecPath,"/"),	
			case lists:member("viewvc",Parts) of
			true ->
				%Do something with DecPath & QueryPart
				case QueryPart of
				[] ->
					%% Rewritten = SomeNewpath;
				_Other ->
					%% Rewritten = SomeNewpath ++ "?" ++ QueryPart

			  	Req2 = Req#http_request{path = {abs_path, Rewritten}},

				ARG2 = ARG#arg{req = Req2};			
			false -> 		
				ARG2 = ARG
        _Else ->
		ARG2 = ARG



Great job! I improved the code to make Yaws work with PHP Zend Framework. Go to for more information. It is quite possible that it will also work for other frameworks (like Cake, for example) – though I haven’t tested it personally.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.