Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 96810 invoked from network); 17 Jan 2008 15:02:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jan 2008 15:02:36 -0000 Received: (qmail 10415 invoked by uid 500); 17 Jan 2008 15:02:22 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 10315 invoked by uid 500); 17 Jan 2008 15:02:22 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 10264 invoked by uid 99); 17 Jan 2008 15:02:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jan 2008 07:02:22 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [166.70.186.42] (HELO onyx.sharktooth.org) (166.70.186.42) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jan 2008 15:01:55 +0000 Received: from corvette.dnsdhcp.provo.novell.com ([137.65.53.197]) by onyx.sharktooth.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1JFW7P-0002cI-Gi for modules-dev@httpd.apache.org; Thu, 17 Jan 2008 07:53:24 -0700 Message-ID: <478F6DE6.7050206@joe-lewis.com> Date: Thu, 17 Jan 2008 08:01:58 -0700 From: Joe Lewis User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: modules-dev@httpd.apache.org References: <1404e5910801160642g2ec6c452td648c72ae2017bf0@mail.gmail.com> <9dc7421e0801161409sb7eb7bdl827669e32a886ab8@mail.gmail.com> <1200522197l.26295l.3l@raydesk1.bettercgi.com> <9dc7421e0801161434m37fc988cp7889dc5234395853@mail.gmail.com> <9dc7421e0801170225i2a96603bn7915293196fc4534@mail.gmail.com> In-Reply-To: <9dc7421e0801170225i2a96603bn7915293196fc4534@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 137.65.53.197 X-SA-Exim-Mail-From: joe@joe-lewis.com X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on onyx.sharktooth.org X-Spam-Level: Subject: Re: [Module Dev] Sending http request X-SA-Exim-Version: 4.2 X-SA-Exim-Scanned: Yes (on onyx.sharktooth.org) X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED autolearn=failed version=3.1.7 karim Bendadda wrote: > Hi All; > > I tried this > > *request_rec *subr = ap_sub_req_lookup_uri(url, r, NULL); > apr_table_set( subr->headers_out, "Location", url ); > ap_log_rerror( APLOG_MARK, APLOG_ERR, 0,r, "sub request status: > %i",subr->status ); > ap_run_sub_req(subr);* > > I have the following error: > > *[Thu Jan 17 07:11:25 2008] [error] [client 10.75.197.168] File does not > exist: /usr/local/apache2/htdocs/my_module* > > I think because the external server is not on the same site..I read the > paragraph 6.3 Diverting a Request: The internal redirect ...I think there is > no external redirect for http requests... > Any suggestion please?? > That error and assumption are correct. As Ray stated, the ap_sub_req_lookup_uri only works if the URI is on the local server's apache. (It is a URI vs. URL concept - the URI does not include the http://servername piece of the URL.) Instead, try a simple : r->filename = apr_pstrcat(r->pool, "proxy:", url, NULL); return 1; (this example was stolen from mod_rewrite, which was the only core module that I was aware of that included a "send to proxy" command). Just set the URL to what the client would have been grabbing if it was redirected to the right page. For example, if the client is trying to get the page http://corvette.sharktooth.org/status.html , the resulting line would be : url = apr_pstrdup(r->pool,"http://corvette.sharktooth.org/status.html"); r->filename = apr_pstrcat(r->pool, "proxy:", url, NULL); return 1; (this could also be shortened - what the three lines do are 1) get/set the URL, which should be set in your case already, 2) preface the URL with "proxy:", which is an indicator to proxy the request elsewhere, and 3) allow apache to handle the rest of the request). Try it and let us know if that works for you. Joe -- Joseph Lewis "Divide the fire, and you will sooner put it out." - Publius Syrus