: Would it not be easier to inject the hostname into the rewrite rule via a RewriteCond back-reference? UseCanonicalName Off # include the IP address in the logs so they may be split LogFormat
Would it not be easier to inject the hostname into the rewrite rule via a RewriteCond back-reference?
UseCanonicalName Off
# include the IP address in the logs so they may be split
LogFormat "%A %h %l %u %t "%r" %s %b" vcommon
CustomLog /var/log/apache2/vaccess.log vcommon
RewriteEngine On
# a ServerName derived from a Host: header may be any case at all
RewriteMap lowercase int:tolower
## deal with normal documents first:
# do the magic
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+).abc.domain.tld$
RewriteRule ^(.*)$ /var/www/abc.domain.tld/%1/ [L]
See mod_rewrite documentation, under RewriteRule "back-references." Notice the use of the %1 instead of the backreference. This should grab the contents of the regular expression sub-match in the RewriteCond above. I have added parenthesis to submatch the 'xxx' portion in the RewriteCond.
More posts by @XinRu657
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.