RE: Comparing environmental variables in httpd.conf for conditional logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was sure something was possible too, two days later I'm starting to
believe Joshua now.  The problem seems to be having the environment
variable in the regex side of the rewritecond statement.

Thanks for the reply

Chris West
Information Analyst
EDS - UKIMEA Commercial AIU
WoodHill House (2nd Floor)
Westburn Road
Aberdeen AB16 5GB
 
( Phone:+44 (0)1224 422517)
+ mailto:chris.west@xxxxxxx

This email contains information which is confidential 
and may be privileged. Unless you are the intended 
addressee (or authorised to receive for the addressee) 
you may not use, forward, copy or disclose to anyone 
this email or any information contained in this email. If 
you have received this email in error, please advise 
the sender by reply email immediately and delete this email.

Electronic Data Systems Ltd
Registered Office:, Lansdowne House, Berkeley Square, London  W1J 6ER 
Registered in England no: 53419
VAT number: 432 99 5915

-----Original Message-----
From: Neil A. Hillard [mailto:neil.hillard@xxxxxxxxxxxxxxxxxx] 
Sent: 21 May 2007 16:33
To: users@xxxxxxxxxxxxxxxx
Subject: Re:  Comparing environmental variables in
httpd.conf for conditional logic

Hi,

Joshua Slive wrote:
> On 5/21/07, Krist van Besien <krist.vanbesien@xxxxxxxxx> wrote:
>> On 5/21/07, West, Chris <chris.west@xxxxxxx> wrote:
>> > Hi Krist,
>> >
>> > Sorry to get back to you again, I have tried the format you 
>> > described and still have problems, is the following how you would 
>> > expect the rewrite condition to look?  I have tried both, neither 
>> > giving the
>> result
>> > expected.
>> >
>> > 1.
>> >
>> >     RewriteCond %{HTTP_REFERER} ^.*%{ENV:SERVER_NAME}.*$ [OR]
>> >     RewriteCond %{HTTP_REFERER} ^$
>> >     RewriteRule .* - [E=dont_log_referer:true]
>> >
>> > 2.
>> >
>> >     RewriteCond %{ENV:HTTP_REFERER} ^.*%{ENV:SERVER_NAME}.*$ [OR]
>> >     RewriteCond %{ENV:HTTP_REFERER} ^$
>> >     RewriteRule .* - [E=dont_log_referer:true]
>>
>> After your other mail I know know that it is the "internal variable"
>> SERVER_NAME that you want to test against, and in this case 
>> %{SERVER_NAME} ought to be correct. %{HTTP_REFERER} is also correct.
>>
>> What could be your problem is that SERVER_NAME is not containing what

>> you expect, and that therefore the rule doesn't match. Have you tried

>> turning rewritelog on, and setting the loglevel to 9? This ought to 
>> give you a ton of information.
> 
> In any case, this isn't going to work. The regular expression used in 
> RewriteCond (and RewriteRule and SetEnvIf) cannot contain variables.
> It is compiled at server-start and doesn't have access to anything 
> per-request.
> 
> I don't think there is any way to do exactly what you want with 
> standard modules. You'll need to specify the ServerName explicitly in 
> the rules.

I don't believe that's true.  I have the following rewrite to remove a
prefix from the REMOTE_USER variable:

RewriteCond        %{LA-U:REMOTE_USER} ^EXT_(.*)$
RewriteRule        .* - [env=RU:%1]

and:

RewriteRule ^/$ http://%{SERVER_NAME}/site/ [R]


I haven't got a spare server to play around with at the moment, but I'm
sure something is possible.  Is it just a case of it doesn't like the
environment variable on the RHS argument?

As someone else asked, have you enabled the RewriteLog?


HTH,


				Neil.

-- 
Neil Hillard                    neil.hillard@xxxxxxxxxxxxxxxxxx
AgustaWestland                  http://www.whl.co.uk/

Disclaimer: This message does not necessarily reflect the
            views of Westland Helicopters Ltd.

---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux