Arthur Ronconi
Arthur Ronconi

Reputation: 2428

Can I use variables in <Directory> (Apache 2.4)?

I'm working with virtual hosts. I've created a _wordpress.conf file:

# WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

... and included it in my vhosts.conf

<VirtualHost *:80>
  ServerName example.org
  DocumentRoot /var/www/example.org
  <Directory /var/www/example.org>
    Include _wordpress.conf
  </Directory>
</VirtualHost>

The configuration only works with the Directory tag. I want to simplify this configuration like:

# _wordpress.conf
<Directory %{DOCUMENT_ROOT}>
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
</Directory>

And...

# vhosts.conf
<VirtualHost *:80>
  ServerName example.org
  DocumentRoot /var/www/example.org
  Include _wordpress.conf
</VirtualHost>

It's possible? I've tried a lot and have no success... =/

Upvotes: 1

Views: 296

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58563

Look at using the mod_macro module for Apache.

Upvotes: 2

Related Questions