简体   繁体   English

如何在Apache中通过URL设置HTTP标头差异

[英]How to set HTTP header difference by URL in Apache

I try to set Apache/2.4.25 (Debian) (via docker) form this post but that's not work for me. 我试图通过这篇文章设置Apache / 2.4.25(Debian)(通过docker),但这对我不起作用。

Configuration file like. 配置文件之类的。

  Header set Test-1 %{THE_REQUEST}e
  <If "%{REQUEST_URI} != '/en'">
    Header set Test-2 %{REQUEST_URI}e
  </If>

When call GET /en HTTP header is 当调用GET / en HTTP头是

  Test-1: (null)
  Test-2: /en

How do I fix it? 我如何解决它?

You need to use %{REQUEST_URI}e instead of %{THE_REQUEST}e . 您需要使用%{REQUEST_URI}e而不是%{THE_REQUEST}e

You can also simplify this by using: 您还可以使用以下方法简化此操作:

Header set Test-1 %{REQUEST_URI}e

SetEnvIf Request_URI "^/(?!en/?$)" NO_EN
Header set Test-2 %{REQUEST_URI}e env=NO_EN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM