This should do it:
RewriteCond %{HTTP_HOST} ^(www\.)?(.+) RewriteCond ${domainmappings:%2} ^(.+)$ [NC] RewriteRule ^ /%1 [L,R=301]
The first RewriteCond
will remove the optional www.
prefix www.
. The rest is then used as a parameter for the rewriting card in the second RewriteCond
.
The overwrite map of a plain text file returns an empty string if no match is found:
If the key is found, the map-function construct is replaced with SubstValue. If the key is not found, it is replaced by DefaultValue or an empty string if the value of DefaultValue is not specified.
So, if the second condition is met (note ^(.+)$
), A match is found, and %1
will contain SubstValue (in this case file.php
).
Gumbo
source share