Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
.htaccess setEnv as %{HTTP_HOST}

is it possible to do the htaccess SetEnv with %{HTTP_HOST}?

i try it like this:

SetEnv HOSTNAME %{HTTP_HOST}

but this doesen't work. i tested it with setting it like

SetEnv HOSTNAME localhost.work

and thats working. So it's just my configuration whats not really operating.

Hope someone can give me a quick hint why this isn't working.

Thanks in advance.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

SetEnv (mod_env) is for setting simple hardcoded name/value pairs. You need to use SetEnvIf (mod_setenvif) if you want to set the var based on elements of the request.

For example, to set the env var HOSTNAME to the value of the Host HTTP request header:

SetEnvIf Host "(.*)" HOSTNAME=$1

The SetEnvIf directive sets the environment variable conditionally... if the regex ((.*)) matches the the first argument (ie. the HTTP Host header) then it sets the env var.

Host refers to the Host HTTP request header (the same as the HTTP_HOST server variable). (.*) is the capturing regex that this matches against and $1 is a backreference to this captured pattern.

Reference:
https://httpd.apache.org/docs/2.4/mod/mod_setenvif.html#setenvif

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda