You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Lesley Kimmel <lj...@hotmail.com> on 2014/09/26 15:20:02 UTC
[users@httpd] Apache 2.2 RewriteRule/Proxypass and general processing flow
Hi All!
I'll try to make this as short as I can, but I need some assistance in understanding the Apache processing flow. I am using Apache 2.2
I have a requirement to disable access to a certain context (say, /xyz) for users of Firefox. From what I can gather the best way to do this is using mod_rewrite and a RewriteCond %{HTTP_USER_AGENT}. I also had a proxypass in place for this context and found that no matter where I placed my RewriteRule the proxy always seemed to occur. This leads me to believe that proxypass takes precedence over RewriteRule, can you confirm this? So, I ended up with this configuration:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} Firefox
RewriteRule ^xyz error/go_away.html [L] # Message displayed from DOCUMENT_ROOT/error/go_away.html
RewriteRule ^xyz(.*)$ http://targetserver/xyz$1 [P]
I also have a ProxypassReverse outside of the directory block to handle redirects.
In the end I got this to work by including it in the 'Document Root' Directory block. However, I'd like to understand why when I placed it outside of this Directory block it would seem to be ignored. I would get an error when accessing the URL that this URL was not found on the server. From some research I was to believe that mod_rewrite generally hooks itself early into the process so I would think that a server-level directive would be processed pretty much before anything else. Why does it act like the rules don't even exist if placed outside of the directory block?
Thanks
-Kimmel
RE: [users@httpd] Apache 2.2 RewriteRule/Proxypass and general
processing flow
Posted by Lesley Kimmel <lj...@hotmail.com>.
Ok, thanks for that. Can you explain a little more about that?
I did see some stuff but didn't fully grasp it. I did try the same rules with the preceding '/' which is apparently how one would do it at the server level, but that didn't seem to make a difference. How do I change the context of my rules to exist at the server level?
Thanks again,
-Kimmel
Date: Fri, 26 Sep 2014 09:26:10 -0400
From: covener@gmail.com
To: users@httpd.apache.org
Subject: Re: [users@httpd] Apache 2.2 RewriteRule/Proxypass and general processing flow
On Fri, Sep 26, 2014 at 9:20 AM, Lesley Kimmel <lj...@hotmail.com> wrote:
This leads me to believe that proxypass takes precedence over RewriteRule, can you confirm this?
Depends on the context of your RewriteRules. Yours imply <directory> or htaccess which runs later. ProxyPass happens before (instead of) the URL has been mapped to any directory.
--
Eric Covener
covener@gmail.com
Re: [users@httpd] Apache 2.2 RewriteRule/Proxypass and general
processing flow
Posted by Eric Covener <co...@gmail.com>.
On Fri, Sep 26, 2014 at 9:20 AM, Lesley Kimmel <lj...@hotmail.com>
wrote:
> This leads me to believe that proxypass takes precedence over RewriteRule,
> can you confirm this?
Depends on the context of your RewriteRules. Yours imply <directory> or
htaccess which runs later. ProxyPass happens before (instead of) the URL
has been mapped to any directory.
--
Eric Covener
covener@gmail.com