httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Igor Cicimov <icici...@gmail.com>
Subject Re: [users@httpd] Problem when mixing RewriteRules and <Location> directives
Date Wed, 21 Mar 2012 09:15:43 GMT
Ummmm if you read your post you will find that you have answered your own
question. The /onlinestore/checkout matches your rewrite rule thus gets
redirected to index.php before the Location statement gets into action. I
think you need to read the apache documentation about the order in which
the rules and statements get executed.
On Mar 21, 2012 8:02 PM, "Bruno Tréguier" <Bruno.Treguier@shom.fr> wrote:

> Hello there,
>
> I presently have a problem when trying to mix RewriteRules and <Location>
> directives. I searched the list archives but didn't find anything similar
> to my situation. Let's try to be synthetic. Here are the relevant config
> directives:
>
> At "VirtualHost" level, among other things, here are the RewriteRules I'm
> using:
>
> RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteCond %{REQUEST_FILENAME} !-l
> RewriteRule .* index.php [L]
>
> This set of RewriteRules are used with an online payment solution called
> "Magento". The idea, rather classical, is that the file "index.php" is a
> catch-all script, dealing with any URI which is not included in the
> exceptions above (typically, media files that are served "statically", or
> files really existing on the underlying filesystem).
>
> So far, so good.
>
> Now, what I want to do is add certain headers depending on the Request
> URI. Here is how I thought I could do it:
>
> <Location /onlinestore/checkout>
>  Header Add X-MyTraceHeader "CheckingOut"
> </Location>
>
> But it doesn't work, the header is never present in the server response...
> However, if I use the same method with a URI corresponding to a *real* file
> (e.g. a media file), so that the RewriteConds prevent the RewriteRule from
> being executed, it works perfectly !
>
> So, it seems that the URI (held in the env. variable REQUEST_URI) is
> rewritten "in place" by the RewriteRule, meanwhile it's the one that is
> used by <Location> directive as well !
>
> I tried another method, quite similar, via mod_setenvif:
>
> SetenvIf REQUEST_URI "/onlinestore/checkout" CheckingOut=1
> Header Add X-MyTraceHeader "CheckingOut" env=CheckingOut
>
> But to no avail.
>
> Any idea or pointer ?
>
> Thanks in advance !
>
> Best regards,
>
> Bruno
>
> --
> - Service Hydrographique et Oceanographique de la Marine  -  DMGS/INF
> -  13, rue du Chatellier -  CS 92803  - 29228 Brest Cedex 2, FRANCE
> -     Phone: +33 2 98 22 17 49  -  Email: Bruno.Treguier@shom.fr
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@httpd.**apache.org<users-unsubscribe@httpd.apache.org>
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Mime
View raw message