Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
.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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda