You can serve one codebase and swap text based on the requested domain by using Apache’s Host header + either SSI (server-side includes) or mod_substitute. Here are two solid patterns—pick the one you like.
Option A: SSI (clean & fast for “static” sites)
1) Enable needed modules
a2enmod headers rewrite include
systemctl reload apache2
2) Single vhost with many domains, one DocumentRoot
<VirtualHost *:80>
ServerName motoshowcase.example # any primary
ServerAlias motosare.in motosare.jp motosare.us motosare.co.uk
DocumentRoot /var/www/motoshare-site
# allow SSI on .html files
Options +Includes
AddType text/html .html
AddOutputFilter INCLUDES .html
# Set country/domain/email per Host
<If "%{HTTP_HOST} == 'motoshare.in'">
SetEnv COUNTRY "India"
SetEnv DOMAIN "motoshare.in"
SetEnv SUPPORT_EMAIL "support@motoshare.in"
</If>
<ElseIf "%{HTTP_HOST} == 'motoshare.jp'">
SetEnv COUNTRY "Japan"
SetEnv DOMAIN "motoshare.jp"
SetEnv SUPPORT_EMAIL "support@motoshare.jp"
</ElseIf>
<ElseIf "%{HTTP_HOST} == 'motoshare.us'">
SetEnv COUNTRY "United States"
SetEnv DOMAIN "motoshare.us"
SetEnv SUPPORT_EMAIL "support@motoshare.us"
</ElseIf>
# ...add the rest of your domains here...
# (Optional) log host & referer to verify mapping
LogFormat "%h %l %u %t \"%r\" %>s %b HOST=\"%{Host}i\" REF=\"%{Referer}i\" UA=\"%{User-Agent}i\"" hostfmt
CustomLog ${APACHE_LOG_DIR}/access.log hostfmt
</VirtualHost>
3) Use SSI variables inside your HTML
Change your pages from pure .html
to SSI-enabled .html
(we enabled INCLUDES for .html above). Wherever you want domain/country/email to appear, use:
<h1>Welcome to <!--#echo var="COUNTRY" -->!</h1>
<p>You’re visiting <!--#echo var="DOMAIN" -->.</p>
<p>Contact us: <a href="mailto:<!--#echo var='SUPPORT_EMAIL' -->">
<!--#echo var="SUPPORT_EMAIL" --></a></p>
That’s it. The same file renders different values depending on HTTP_HOST
.
Tip: If you prefer to keep files as .shtml
instead, change AddOutputFilter INCLUDES .html
to .shtml
and rename files accordingly.
Option B: Token replacement with mod_substitute (no SSI tags)
If you’d rather keep plain tokens like __COUNTRY__
in your HTML:
1) Enable module
a2enmod substitute
systemctl reload apache2
2) Single vhost config
<VirtualHost *:80>
ServerName motoshowcase.example
ServerAlias motosare.in motosare.jp motosare.us
DocumentRoot /var/www/motoshare-site
# Env mapping per domain
<If "%{HTTP_HOST} == 'motoshare.in'">
SetEnv COUNTRY "India"
SetEnv DOMAIN "motoshare.in"
SetEnv SUPPORT_EMAIL "support@motoshare.in"
</If>
<ElseIf "%{HTTP_HOST} == 'motoshare.jp'">
SetEnv COUNTRY "Japan"
SetEnv DOMAIN "motoshare.jp"
SetEnv SUPPORT_EMAIL "support@motoshare.jp"
</ElseIf>
<ElseIf "%{HTTP_HOST} == 'motoshare.us'">
SetEnv COUNTRY "United States"
SetEnv DOMAIN "motoshare.us"
SetEnv SUPPORT_EMAIL "support@motoshare.us"
</ElseIf>
# Replace tokens in HTML responses
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s/__COUNTRY__/%%{env:COUNTRY}/n"
Substitute "s/__DOMAIN__/%%{env:DOMAIN}/n"
Substitute "s/__SUPPORT_EMAIL__/%%{env:SUPPORT_EMAIL}/n"
</VirtualHost>
3) In your HTML, use tokens
<h1>Welcome to __COUNTRY__!</h1>
<p>You’re visiting __DOMAIN__.</p>
<p>Contact us: <a href="mailto:__SUPPORT_EMAIL__">__SUPPORT_EMAIL__</a></p>
Apache will swap tokens per request based on the domain.
When to pick which?
- SSI: Neat if you’re fine adding a few
<!--#echo-->
tags; very lightweight and explicit.
- mod_substitute: Keep HTML “static-looking” with simple placeholders.
Both approaches:
- Work from a single DocumentRoot for all domains.
- Dynamically inject country, domain, and support email based on the Host header.
- Don’t require PHP or an app server.
If you want, tell me your full list of 10 domains + desired country/email for each, and I’ll generate the exact Apache block for you.