I was tring to run php5-cgi with redirect module, and it failed.
And watching roxen source, these small patch make php5-cgi run as I
expected.
Add redirect entry below in Redirect Module:
/([^\?]*)\.php(/*)([^\?]*)(\?*.*)$ /cgi-bin/php5/$1.php$2$3$4
Apply two patches below for modules/filters/redirect.pike and
modules/scripting/cgi.pike.
Then to make correct(?) path_translated for url with pathinfo
redirected, modified etc/modules/Roxen.pmod like third patch.
And finally I can access php5 script in roxen. This also work for
php5 as fastcgi, but roxen fastcgi module output is doubled(Bug #4069)
Are these in correct way? Are there more better way?
$ telnet roxen40 http
Trying 192.168.64.231...
Connected to roxen40.localnet.
Escape character is '^]'.
GET /test.php HTTP/1.0
HTTP/1.0 200 OK
Content-type: text/html
X-Powered-By: PHP/5.0.5-3
Server: Roxen/4.0.425-release5
<html>
<body>
Hello world<br/></body>
</html>
Connection closed by foreign host.
--- redirect.pike.~1.40.~ 2005-08-16 20:39:55.000000000 +0900
+++ redirect.pike 2006-01-06 00:40:45.000000000 +0900
@@ -274,6 +274,7 @@
return Roxen.http_low_answer( 302, "")
+ ([ "extra_heads":([ "Location":to ]) ]);
} else {
+ id->misc->redirected_raw_url = id->raw_url;
id->variables = FakedVariables(id->real_variables = ([]));
id->raw_url = Roxen.http_encode_string(to);
id->not_query = id->scan_for_query( to );
--- cgi.pike.~2.62.~ 2004-07-01 01:59:19.000000000 +0900
+++ cgi.pike 2006-01-06 01:04:27.000000000 +0900
@@ -864,8 +864,10 @@
environment |= Roxen.build_roxen_env_vars(id);
if(id->misc->ssi_env)
environment |= id->misc->ssi_env;
- if(id->misc->is_redirected)
+ if(id->misc->is_redirected) {
+ environment["REDIRECT_URL"] =
id->scan_for_query(id->misc->redirected_raw_url);
environment["REDIRECT_STATUS"] = "1";
+ }
if(id->rawauth && query("rawauth"))
environment["HTTP_AUTHORIZATION"] = (string)id->rawauth;
else
--- Roxen.pmod.~1.192.~ 2005-10-28 02:40:25.000000000 +0900
+++ Roxen.pmod 2006-01-06 17:26:07.000000000 +0900
@@ -947,7 +947,7 @@
t2 = id->conf->real_file(path_info, id);
if(t2)
{
- new["PATH_TRANSLATED"] = t2 + t;
+ new["PATH_TRANSLATED"] = t2 + (id->misc->is_redirect &&
t2[-1]=='/'?"":"/") + t;
break;
}
array(string) tmp = path_info/"/" - ();
|