Setting multiple Apache VirtualHosts to same DocumentRoot without url changing

apache-2.2documentrooturlvirtualhost

I'm trying to get domain.fi and domain.com to point to the same DocumentRoot, without the domain changing in the browser url. Is that possible with Apache?

I've got the both domains pointing to the same DocumentRoot and working, but the domain.com changes to domain.fi in the browser url.

Best Answer

Use a Redirect to domain.com within the VirtualHost for domain.fi. For this to work mod_alias must be loaded.

<VirtualHost 127.0.0.1>
        ServerName www.domain.fi
        ServerAlias doman.fi
        RedirectMatch (.*) http://www.domain.com/
</VirtualHost>

You could also specify any standard VirtualHost settings desired, such as CustomLog.

Related Topic