Mobile app version of vmapp.org
Login or Join
XinRu657

: 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

@XinRu657

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.

10% popularity Vote Up Vote Down


Login to follow query

More posts by @XinRu657

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme