使用Apache检查请求中是否存在标头 [英] Check if header is present in request with apache

查看:106
本文介绍了使用Apache检查请求中是否存在标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查标头是否存在。我不想检查值是否与不同,我想使用以下方法检查它是否确实存在:

How can I check if a header exist. I dont want to check if the value is different of "" I want to check if it really exist using:

RewriteCond

RewriteCond

如何在htaccess文件中执行此操作?

How can I do that inside htaccess file?

推荐答案

您可以使用这样的条件来了解标题是否 X-SomeHeader 是否存在:

You can use a condition like this to know if a header X-SomeHeader exists or not:

RewriteEngine On

# block if request header X-SomeHeader doesn't exist
RewriteCond %{HTTP:X-SomeHeader} !^$
RewriteRule ^ - [F]

这篇关于使用Apache检查请求中是否存在标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆