Forum Moderators: phranque
if ($foo =~ /(\w+)/ && $bar =~ /(\w+)/) { ... } if ($foo =~ /(jiggery)(pokery)/ && $bar =~ /(hoity)(toity)/)then $1 would be "jiggery", later replaced by "hoity", while $2 is "pokery" later replaced by "toity". RewriteCond {foo} (jiggery)(pokery) [OR]
RewriteCond {bar} (hoity)(toity)
RewriteRule blahblah /%1%2 [L]{simplified for posting purposes) If the first Condition matches but the second doesn't, then the target is "jiggerypokery"; it the second Condition matches--whether or not the first one did--then it’s "hoitytoity".
if ($foo =~ /(?P<one>\w+)/ && $bar =~ /(?P<two>\w+)/) { ... } if ($foo =~ /(\w+)/) {
$one = $1;
}
if ($one && $bar =~ /(\w+)/) {
$two = $2;
}
if ($one && $two && $this =~ /(\w+)/) {
$three = $3;
}
// and so on Do you really mean (\w+) or are you just simplifying for posting purposes? Otherwise it seems like you could just as well say
if ($foo && $bar && $this && $that)
and so on.
But, again, it probably will help to lay out the real-life issues behind the programming questions.
SetEnvIfExpr "%{ENV:foo} =~ /(.+)/" this=$1 # breaks added for readability
SetEnvIfExpr "-z %{ENV:default} && %{ENV:linker} =~ /^example$/ && %{REQUEST_URI} =~ m#^/(?:foo:bar)([a-z]+)#i"
default=$1
home=%{ENV:home}/$1
'siteName=%{ENV:siteName} - %{ENV:ext} - %{ENV:home} - %{ENV:default}' SetEnvIfExpr "%{ENV:home}|:|%{ENV:linker} =~ /([^|]+)\|:\|(.+)/" home=$1/$2 I can't manually write it since there are 2 potential domains, unless I write 2 identical rules (one for each domain).Sometimes writing the same rule twice may be less trouble than putting together a single hideously complicated rule to do it all at once. Similarly, it is often simpler to first do something globally, and then un-do it in selected situations, rather than put together a “do this thing” rule that does the picking-and-choosing in advance. Obvious example: set a bunch of environmental variables, and then un-set them (“poke holes”) as needed.
I have a more complicated variable where I literally build the logo based on this criteria, too.OK, see, that’s what I was getting at. What is the ultimate purpose of all these environmental variables?
What is the ultimate purpose of all these environmental variables?
In all honesty, I myself would long since have thrown in the towel and done the whole thing in php-or-similar ;)
SetEnvIfExpr "%{ENV:home}|:|%{ENV:linker} =~ /([^|]+)\|:\|(.+)/" home=$1/$2 SetEnvIfExpr "env('home') . '|:|' . env('linker') =~ /([^|]+)\|:\|(.+)/" home=$1/$2 SetEnvIfExpr "env('home') . '|:|' . env('linker') =~ /((?!\|:\|).+?)\|:\|(.*)/" home=$1/$2