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

女生的网名这么多〃 提交于 2019-12-21 05:27:05

问题


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.


回答1:


Try this:

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

Hopefully that helps.



来源:https://stackoverflow.com/questions/11032810/create-an-apache-setenv-variable-with-the-subdomain-name-in-case-of-wildcard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!