0

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.

HBruijn
  • 72,524
  • 21
  • 127
  • 192

1 Answers1

1

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.

Warner
  • 23,440
  • 2
  • 57
  • 69
  • Thank you. That seemed to fix the url problem, but I forgot to tell that the server uses https protocol only, so now the browser warns about an untrusted ssl certificate.. (naturally because the .com url has now the .fi certificate) I'm just trying to get the two domains to point to the same DocumentRoot and work with ssl, but is it possible? –  Mar 26 '10 at 22:16
  • Are you linking the different URL within your site? I don't understand why the Redirect would introduce a SSL error. I need more details. What's the actual domain? – Warner Mar 26 '10 at 22:26
  • No, I'm not linking the URLs. I just need the site to work with both domains when users visit them. I can't tell the actual domain yet, because it hasn't been published yet.. The SSL error comes with the URL www.domain.com but not with domain.com. Our domain.fi and domain.com have different SSL sertificates. –  Mar 26 '10 at 22:39
  • You should be able to setup a https vhost for www.domain.fi and redirect it to https://www.domain.com/. If the CN in the cert matches both vhosts, you shouldn't get SSL errors. – Warner Mar 27 '10 at 03:35
  • The CN only matches one vhost. If we would buy a cert that matches both domains, it would cost a lot more.. So I guess for now we can only use one domain, and just redirect from .fi to .com domain. Thanks for your help. –  Mar 28 '10 at 11:44
  • You're welcome. You can use the SSL technologies listed here as potential alternatives as well http://serverfault.com/questions/126072/ssl-certificate-selection-based-on-host-header-is-it-possible/126075#126075 – Warner Mar 28 '10 at 17:53
  • Now I got it working fully with both domains. I didn't even need the RedirectMatch in the VirtualHost. The solution was so simple that I just had to clear my browser's SSL cache.. Doh.. –  Mar 29 '10 at 20:17