Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the subdomain as a variable in apache config to be used in the same config file:

  1. How to define dynamically the subdomain of wildcard address as a variable in apache configuration file ?
  2. How can I call the enviroment variable in configuration file of apache ? This option here doen't work: Create an Apache SetEnv variable with the subdomain name in case of wildcard It seems it doesn't work.

I've tried:

setting the enviroment virable:

  • SetEnv SUBDOMAIN subdomainx
  • SetEnvIf Host "^([^.]*).domainx.tldx$" SUBDOMAIN=$1
  • SetEnvIf Host "^([^.]*).domainx.tldx$" SUBDOMAIN=specificsubdomainx
  • Define SUBDOMAIN %-3

retrieving the variable in the same config file:

  • ${SUBDOMAIN}
  • %{SUBDOMAIN}
  • SUBDOMAIN

Please help, Its freaking me out. Thanks

like image 503
MyUserInStackOverflow Avatar asked Sep 16 '25 17:09

MyUserInStackOverflow


1 Answers

SetEnvIf Host "^([^.]*).domainx.tldx$" SUBDOMAIN=$1

looks ok (provided the domain you're using it on is *.domainx.tldx)

But you have to reference the variable like this:

%{ENV:SUBDOMAIN}
like image 114
marty Avatar answered Sep 19 '25 08:09

marty