Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
.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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!