Re: rewriting requests

Gasior <[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
David Birnbaum wrote:

> Gasior,
>
> I don't think mod_fastcgi messes with the paths at all.  Take a look
> at mod_rewrite.  I think RewriteBase gives some clues as to how you
> can map a URL to a physical filesystem.  There is probably a way to do
> that with Rewrite and Alias combinations, but requires more wizardry
> than I can offer off the top of my head.
>
> Your information might be nice to put into a FAQ question, once you
> get it all worked out though!
>
> Cheers,
>
> David.
>
> -----

Hi all.

I've done some work with mod_rewrite and here are the results.
Because php binary is executed inside chrooted filesystem, apache has to
rewrite url's to phisical path that doesn't exists for apache process.

Example:
Servername vhost1.com
DocumentRoot /home/vhosts/vhost1.com/www

PHP binary is chrooted in /home/vhosts/vhost1.com so request like this:
http://www.vhosts1.com/test.php will be seen by apache as
/home/vhosts/vhost1.com/www/test.php but PHP should get stripped version
-> /www/test.php

RewriteRule ^/test.php /www/test.php  

mod_rewrite checks if rewrite rule target exists in filesystem and
prefixes with document root if not.

I've managed to get this work by hacking mod_rewrite code not to prefix
target with document root, so even "wrong" rules work. And it works
surprisingly well :)

Of course this could brake mod_rewrite design and become security
problem if you want to provide mod_rewrite to your customers (still
talking about shared ISP environment).


Analyzing apache code is a bit to much for me but if it works like this:

1. apache gets http request to fcgi script (php)
2. apache redirects request to mod_fastcgi process manager
3. process manager writes request to proper pipe
4. request is executed by fastcgi app
...

than it would be possible to manipulate request in step 3 to strip that
damm path.

Regards
Gasior
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.