我可以连接在Apache的配置环境变量? [英] Can I concatenate environment variables in apache config?
本文介绍了我可以连接在Apache的配置环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在apache配置两个环境变量,我想将它们串联成一个新的环境变量。这可能吗?
I have two environment variables in apache config, I want to concatenate them into one new environment variable. Is this possible?
我知道这是不行的,但它表明了诸如此类的事情后,我:
I realise this doesn't work, but it demonstrates the sort of thing I'm after:
SetEnv one foo
SetEnv two bar
SetEnv three one+two
...然后'三'将具有值foobar的
...and then 'three' would have the value "foobar"
推荐答案
使用的 mod_rewrite的定期EX pression有两个通配符反向引用来访问环境变量和连接字符串:
Use a mod_rewrite regular expression with two wildcard backreferences to access the environment variables and concatenate the strings:
#This will be true for any user agent
RewriteCond %{HTTP_USER_AGENT} ^.*
#Replace / with / and set the new environment variable
RewriteRule /(%{ENV:one})*(%{ENV:two})* / [E=three:$1$2]
这篇关于我可以连接在Apache的配置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文