[Mono-list] Rewriting path with an HttpModule

Daniel Lopez daniel@rawbyte.com
Sat, 22 Mar 2003 12:22:17 -0800


> > After fixing RewritePath, i'll modify it and send it back to you.
> 
> Mmm. Well, as RewritePath is more of a 'hide the real URL' thing, and
> after some thinking, I bet for adding the ~user stuff in
> MonoWorkerRequest.

I think it could be done with

MonoApplication /~ /home

and then using RewritePath to rewrite ~user/index.aspx to
~user/public_html/index.aspx internally, which will then
be mapped to /home/user/public_html/index.aspx

> Why? There's one place where you can fake the real path to the file
> (MapPath), so you can map "/~gonzalo/" to the file
> "/home/gonzalo/public_html/index.aspx" or even using a configuration
> file like the one in the link I put in my previous mail.

We can modify Request to support user directories, but it may be better to
create a hook point in MapPath(), that allows you to have arbitrary code
providing that functionality.
What I have in mind is a module that runs the mapped path thru Apache API
and then takes a look at the resulting path_translated filed in the
request_rec structure. This would allow us to reuse all the existing Apache
modules that map virtual paths to physical paths, such as mod_userdir or
mod_rewrite.
That would require that:

a) All MapPath functions eventually call Request.MapPath()  (I did some
greping and think that is the case)
b) Other parts of the code do not make assumptions that physical paths are
rooted in the Application physical path, as for example happens in 
mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
See patch in 
http://lists.ximian.com/archives/public/mono-list/2003-March/012992.html

Cheers

Daniel