apache如果条件-HTTP标头参数

发布于 2025-01-30 15:51:40 字数 469 浏览 4 评论 0原文

我对VHOST规则的条件有一个疑问。 我只需要在存在特定的参数中添加并包括重定向文件。

我认为我可以做类似的事情:

<If "%{HTTP:X-block-redirect} in { 'false' }">
 IncludeOptional ...
</If>

但是我仍然认为我缺少一些东西。 例如,如果不存在块状重新定位(或者像我的条件一样是错误的),则应添加include-optional文件,但如果是正确的,则不应。

我认为与类似的条件相匹配:

<If "%{HTTP:X-block-redirect} **not** in { 'true' }"> 
...
</If>

可以更好地工作,但是我正在努力创建一个像“如果不是这样,那就这样做” ... 你能帮助我吗?

多谢!

I have a question about an condition into vhost rules.
I need to add and IncludeOptional redirects files only if a specific param into the header is present.

I think that I can do something like:

<If "%{HTTP:X-block-redirect} in { 'false' }">
 IncludeOptional ...
</If>

but I still think that i'm missing something.
For example, If the block-redirect is not present (or it's false like my If condition), it should add the IncludeOptional files but if it's true it shouldn't.

I think that a condition that match something like:

<If "%{HTTP:X-block-redirect} **not** in { 'true' }"> 
...
</If>

can work better but I'm struggling on how to create an if like "if NOT this DO that"...
Can you help me?

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南…巷孤猫 2025-02-06 15:51:40

为了解决此问题,我刚刚使用了一个(and Simple)!='true'条件。

<If "%{HTTP:X-value} !='true'">
 IncludeOptional ...
</If>

我以为我无法检查一个值,而不是一个值,但我错了。

我希望该解决方案可以帮助其他问题的人!

In order to resolve this I've just used a single (and simple) !='true' condition.

<If "%{HTTP:X-value} !='true'">
 IncludeOptional ...
</If>

I thought I could not check a single value instead of an array of values, but I was wrong.

I hope this solution can help someone else with similar problems!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文