On Wednesday 10 November 2010, Stefan Fritsch wrote:
> > The frequency with which this gets asked seems to make it
> > worthwhile doing something, even if this patch isn't the right
> > thing to do.
> 
> Maybe the larger solution of having a document_root field in the 
> request_rec would be better. Has anyone had a chance to look at 
> Ondrej's patch, already? I didn't get around to doing it, yet.
> 
> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705

I have looked at the patch and it looks reasonable. The fact that two 
known modules (mod_vhost_ldap and mod_ftp) copy the whole server_rec 
just to change the document root means that this feature is needed.

Well, at least for mod_ftp it is...

I am wondering if the people who want this for mod_vhost_* actually 
want something else, namely an easy way to get the root dir of a web 
application in php/cgi/whatever...

What about this idea:

Add two new cgi env variables: CONTEXT_ROOT and CONTEXT_ROOT_PATH (or 
APP_ROOT/APP_ROOT_PATH or ...). And add a new config directive

ContextRoot /some/app/

For all requests below /some/app/, this would set CONTEXT_ROOT to
/some/app/ and CONTEXT_ROOT_PATH to whatever dir this URL maps to in 
the file system (taking into account mod_userdir, mod_alias, etc.). 
This would make it easier for applications to find their files and to 
create self-referential URLs.

In absense of a ContextRoot directive, the variables would be set to 
the current alias root-uri and dir, or to the document root and "/". 
Mod_userdir could set them to the /~user/ and /home/user/public_html.

There could even be some logic in mod_proxy that passes the correct 
URI to the backend server, so that the CONTEXT_ROOT variable would 
actually represent the URI as seen by the client.

Is this a good idea? Would this solve real-world problems?

Reply via email to