From: GOTOU Yuuzou Date: 2004-11-30T04:07:30+09:00 Subject: Re: [WEBrick] howto rewrite url In message , `Simon Strandgaard ' wrote: > I have searched on google, but couldn't find any useful info on this. > For instance I would like to rename urls from "show-all.html" to "show.cgi?all". If the modified URL is allowed to be accessed directly, redirection is easy to do it. require "webrick" request_callback = Proc.new{|req, res| if %r{/show-all.html$} =~ req.path_info res.set_redirect(WEBrick::HTTPStatus::Found, "show.cgi?all") end } httpd = WEBrick::HTTPServer.new( :Port=>10080, :RequestCallback => request_callback, :DocumentRoot => Dir.pwd ) trap(:INT){ httpd.shutdown } httpd.start -- gotoyuzo