5

Is there a way to use the DocumentRoot as a variable in further sections of a site's config file in Apache?

Something as below:

DocumentRoot /var/www/myNiceRoot

<Directory $DocumentRoot/mySubDir> ... </>
5

You can define a variable and then use that

Define droot /var/www/html

and then use it later

DocumentRoot ${droot}/site1

and so on.

2
  • A nice solution indeed. My question was assuming adding a section to the file without changing anything else. This would still do, provided I create a site file from the very beginning with such variable in it. – a1an Jan 25 '16 at 14:03
  • You can define them in different scopes - look at the docs. – user9517 Jan 25 '16 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.