0

If request is coming from http://xxx.domain.com,

i want to be able to say;

DocumentRoot /home/${SUBDOMAIN_NAME}

so that Virtual host's DocumentRoot will be assigned to /home/xxx

Any way I can accomplish this?

Thanks, D

ps: please don't worry about security or how bad this idea is. I have over-simplified the problem for the sake of simplicity.

Real usage will be as follows:

<IfModule mpm_itk_module> AssignUserId ${SUBDOMAIN_NAME} usergroup </IfModule>

There will be a unix user with the corresponding subdomain name.

Devrim
  • 1,197
  • 4
  • 16
  • 29
  • I will also accept "no you can't" as an answer if you don't mind explaining why. – Devrim Nov 13 '09 at 22:25
  • I know all these variables are set at the time when apache reloads ( so there is no request coming in at the time of restart), but sometimes there are workarounds (such as http://httpd.apache.org/docs/1.3/vhosts/mass.html) I'm hoping maybe there is something for us as well. – Devrim Nov 14 '09 at 01:20

3 Answers3

2

I think what you are looking for is mass virtual hosting: http://httpd.apache.org/docs/1.3/vhosts/mass.html

Or http://httpd.apache.org/docs/1.3/mod/mod_vhost_alias.html

You probably want something like:

UseCanonicalName    Off
VirtualDocumentRoot /home/%-1

%-1 would get the subdomain.

Read the sites listed for more information.

Natalie Adams
  • 745
  • 1
  • 6
  • 15
0

Answer is provided by Jeff.

Using URL within Vhost container with mod_perl dynamically

Devrim
  • 1,197
  • 4
  • 16
  • 29
-1
NameVirtualHost *:80

<VirtualHost *:80>
ServerName xxx.example.com
DocumentRoot /www/xxx
</VirtualHost>

<VirtualHost *:80>
ServerName yyy.example.com
DocumentRoot /www/yyy
</VirtualHost>

above is a simple example of name-based...you can also use ip based:

<VirtualHost xxx.example.com>
ServerAdmin webmaster@example.com
DocumentRoot /groups/example/xxx
ServerName xxx.example.com
ErrorLog /groups/example_xxx/logs/error_log
TransferLog /groups/example_xxxx/logs/access_log
</VirtualHost>

<VirtualHost yyy.example.com>
ServerAdmin webmaster@example.com
DocumentRoot /groups/example/yyy
ServerName yyy.example.com
ErrorLog /groups/example_yyy/logs/error_log
TransferLog /groups/example_yyy/logs/access_log
</VirtualHost>
user6373
  • 174
  • 4