2
2
2byte2015-03-16 01:01:24
Apache HTTP Server
2byte, 2015-03-16 01:01:24

Apache2 virtualhost use dynamic subdomain as variable?

I need to get the name of the dynamic subdomain in a variable so that I can insert its name into the path.

<VirtualHost *:80>
  ServerAdmin [email protected]
  ServerName projects.dev
  ServerAlias *.projects.dev
  
  VirtualDocumentRoot /mnt/hgfs/Ubuntu/public_html/projects/projects.dev/%1/html

  <Directory />
    Options FollowSymLinks
    AllowOverride all
    Require all denied
  </Directory>
  <Directory /mnt/hgfs/Ubuntu/public_html/projects/projects.dev/*/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    DirectoryIndex index.php
    Require all granted
  </Directory>

  
  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  #CustomLog /mnt/hgfs/Ubuntu/public_html/projects/projects.dev/logs/access.log combined
  #ErrorLog /mnt/hgfs/Ubuntu/public_html/projects/projects.dev/logs/error.log
  
  #php_flag log_errors on
  #php_value error_log /mnt/hgfs/Ubuntu/public_html/projects/projects.dev/%-3/logs/php_error.log

  #php_admin_value upload_tmp_dir /mnt/hgfs/Ubuntu/public_html/projects/projects.dev/%-3/tmp
</VirtualHost>

The config is working, the subdomain name is substituted into the VirtualDocumentRoot path, everything is fine.
But the path to the log will not work /mnt/hgfs/Ubuntu/public_html/projects/projects.dev/%1/logs
Is it possible to create a variable with its name?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question