Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create an Apache SetEnv variable with the subdomain name in case of wildcard

I have a website that is basically set up as this: client_name.website.com

...where clientname is actually a wildcard. For every new customer, I create a subdomain basically.

I need to automatically get the client name info directly from Apache. For example, if one comes throught: client1.website.com ...I would like to have apache do a SetEnv CLIENT_NAME client1 for me.

Since I work with wildcard, it would be nice if this SetEnv would be done dynamically. Really pratical for great amounts of customers.

How would you achieve this ? Thanks in advance.

like image 733
Julien Avatar asked Dec 05 '22 16:12

Julien


1 Answers

Try this:

SetEnvIf Host "^([^\.]*)\.website\.com$" CLIENT_NAME=$1

Hopefully that helps.

like image 122
clmarquart Avatar answered Jan 26 '23 06:01

clmarquart