You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jeff Murch <jm...@cox.net> on 2007/07/24 02:00:39 UTC

[users@httpd] Help!! mod_rewrite location header cant get correct syntax

I need to rewrite a location header as follows but I can't seem to get the
syntax correct:

 

RewriteRule ^Location: http://server1.domain.com  Location:
server2.domain.com [R,L]

 

I know I have to have a delimiter between old and new values?

 

Jeff

 

 

 

 

 

 

 

 


Re: [users@httpd] Help!! mod_rewrite location header cant get correct syntax

Posted by Joshua Slive <jo...@slive.ca>.
On 7/23/07, Jeff Murch <jm...@cox.net> wrote:
> Joshua,
>
> I appreciate the help and the good answers.  I have one last (At least for
> this project) problem.  I'm using mod_proxy_html and expecting it to rewrite
> the HTML links on my reverse proxied pages. It is on the HTML but not
> anywhere within the js.  I am going to see if I have an older version but
> I'm pretty sure I built it from the source on the webthing page.  Any ideas
> what to check for?

I don't know much about mod_proxy_html. But you'd need to start by
specifying exactly where the js is living in the pages.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Help!! mod_rewrite location header cant get correct syntax

Posted by Jeff Murch <jm...@cox.net>.
Joshua,

I appreciate the help and the good answers.  I have one last (At least for
this project) problem.  I'm using mod_proxy_html and expecting it to rewrite
the HTML links on my reverse proxied pages. It is on the HTML but not
anywhere within the js.  I am going to see if I have an older version but
I'm pretty sure I built it from the source on the webthing page.  Any ideas
what to check for?

Jeff



-----Original Message-----
From: jslive@gmail.com [mailto:jslive@gmail.com] On Behalf Of Joshua Slive
Sent: Monday, July 23, 2007 7:14 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Help!! mod_rewrite location header cant get
correct syntax

On 7/23/07, Jeff Murch <jm...@cox.net> wrote:
> The source web server is sending it as a redirect and it is redirecting
the
> browser off my reverse proxy to a site that is not available to the
outside
> world. I've headers unset location and set location "were it should go"
but
> I'd like to be able to use a regex with wildcards.

Are you using the ProxyPassReverse directive? It is designed to handle
exactly this situation.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org



-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.10.14/912 - Release Date: 7/22/2007
7:02 PM



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Help!! mod_rewrite location header cant get correct syntax

Posted by Joshua Slive <jo...@slive.ca>.
On 7/23/07, Jeff Murch <jm...@cox.net> wrote:
> Thanks Joshua. That convinced me to go back and keep trying with the
> ProxyPassReverse directive since I wasn't happy with the header unset.  It
> works fine after I messed with the syntax a bit.
>
> Do you know if you can do conditional header directives such as:
>
> If header = foo.bar.com
> Unset header

Yes, you can do something like
SetEnvIf header ^foo\.bar\.com$ delete-me
Header unset header env=delete-me

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Help!! mod_rewrite location header cant get correct syntax

Posted by Jeff Murch <jm...@cox.net>.
Thanks Joshua. That convinced me to go back and keep trying with the
ProxyPassReverse directive since I wasn't happy with the header unset.  It
works fine after I messed with the syntax a bit. 

Do you know if you can do conditional header directives such as:

If header = foo.bar.com
Unset header


Jeff




-----Original Message-----
From: jslive@gmail.com [mailto:jslive@gmail.com] On Behalf Of Joshua Slive
Sent: Monday, July 23, 2007 7:14 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Help!! mod_rewrite location header cant get
correct syntax

On 7/23/07, Jeff Murch <jm...@cox.net> wrote:
> The source web server is sending it as a redirect and it is redirecting
the
> browser off my reverse proxy to a site that is not available to the
outside
> world. I've headers unset location and set location "were it should go"
but
> I'd like to be able to use a regex with wildcards.

Are you using the ProxyPassReverse directive? It is designed to handle
exactly this situation.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org



-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.10.14/912 - Release Date: 7/22/2007
7:02 PM



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Help!! mod_rewrite location header cant get correct syntax

Posted by Joshua Slive <jo...@slive.ca>.
On 7/23/07, Jeff Murch <jm...@cox.net> wrote:
> The source web server is sending it as a redirect and it is redirecting the
> browser off my reverse proxy to a site that is not available to the outside
> world. I've headers unset location and set location "were it should go" but
> I'd like to be able to use a regex with wildcards.

Are you using the ProxyPassReverse directive? It is designed to handle
exactly this situation.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Help!! mod_rewrite location header cant get correct syntax

Posted by Jeff Murch <jm...@cox.net>.
The source web server is sending it as a redirect and it is redirecting the
browser off my reverse proxy to a site that is not available to the outside
world. I've headers unset location and set location "were it should go" but
I'd like to be able to use a regex with wildcards.

Jeff



-----Original Message-----
From: jslive@gmail.com [mailto:jslive@gmail.com] On Behalf Of Joshua Slive
Sent: Monday, July 23, 2007 6:59 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Help!! mod_rewrite location header cant get
correct syntax

On 7/23/07, Eric Covener <co...@gmail.com> wrote:
> On 7/23/07, Jeff Murch <jm...@cox.net> wrote:
> > I need to rewrite a location header as follows but I can't seem to get
the
> > syntax correct:
> >
> > RewriteRule ^Location: http://server1.domain.com  Location:
> > server2.domain.com [R,L]
>
> Something like this?
>
> RewriteCond %{HTTP:Location} ^http://server1\.domain\.com(.*)
> RewriteRule .* http://server2.domain.com%1 [R,L]

Location is usually a response header, and therefore can't be
rewritten like that. (That notation is for request headers.)

mod_rewrite is probably not the tool for this at all. Why exactly do
you need to rewrite the Location header and in what circumstance?

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org



-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.10.14/912 - Release Date: 7/22/2007
7:02 PM



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Help!! mod_rewrite location header cant get correct syntax

Posted by Joshua Slive <jo...@slive.ca>.
On 7/23/07, Eric Covener <co...@gmail.com> wrote:
> On 7/23/07, Jeff Murch <jm...@cox.net> wrote:
> > I need to rewrite a location header as follows but I can't seem to get the
> > syntax correct:
> >
> > RewriteRule ^Location: http://server1.domain.com  Location:
> > server2.domain.com [R,L]
>
> Something like this?
>
> RewriteCond %{HTTP:Location} ^http://server1\.domain\.com(.*)
> RewriteRule .* http://server2.domain.com%1 [R,L]

Location is usually a response header, and therefore can't be
rewritten like that. (That notation is for request headers.)

mod_rewrite is probably not the tool for this at all. Why exactly do
you need to rewrite the Location header and in what circumstance?

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Help!! mod_rewrite location header cant get correct syntax

Posted by Eric Covener <co...@gmail.com>.
On 7/23/07, Jeff Murch <jm...@cox.net> wrote:
> I need to rewrite a location header as follows but I can't seem to get the
> syntax correct:
>
> RewriteRule ^Location: http://server1.domain.com  Location:
> server2.domain.com [R,L]

Something like this?

RewriteCond %{HTTP:Location} ^http://server1\.domain\.com(.*)
RewriteRule .* http://server2.domain.com%1 [R,L]

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org