Skip to content

Instantly share code, notes, and snippets.

@aikar
Last active October 1, 2023 20:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aikar/b14091c8a600f6bab9fd to your computer and use it in GitHub Desktop.
Save aikar/b14091c8a600f6bab9fd to your computer and use it in GitHub Desktop.
Example of Apache mod_macro
<Macro Site $domain>
Use Log $domain
Use ForceDomain $domain
Use GrantAccess /
</Macro>
<Macro Domain $domain>
ServerName $domain
ServerAlias www.$domain
</Macro>
<Macro GrantAccess $path>
<Location $path>
Order allow,deny
Allow from all
</Location>
</Macro>
<Macro Log $site>
ErrorLog /var/log/apache2/sites/$site_error_log
CustomLog /var/log/apache2/sites/$site_access_log combined
</Macro>
<Macro ForceDomain $domain>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^$domain [NC]
RewriteCond %{HTTPS} =on
RewriteRule (.*) http://$domain/$1 [R,L,QSA]
RewriteCond %{HTTP_HOST} ^$domain [NC]
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://$domain/$1 [R,L,QSA]
</Macro>
<Macro ProxyPass $path $dest>
ProxyPass $path $dest
ProxyPassReverse $path $dest
</Macro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment