I need to get my new domain for example.net to not only respond to the same content as I have for the existing example.com, but I need the user to actually still only see example.net when they get to the site.

I thought this would work simply by using the Apache ServerAlias directive as follows, but one still seems to just get redirected to the .com.

ServerName www.example.com
ServerAlias example.com *.example.com example.net *.example.net

Is this all it should generally take for it to work and keep the example.net domain in the users' address bar? Do I need to create a CNAME record? (my provider does not let me create ALIAS records, if that matters).

Are there multiple ways of accomplishing this?

  • 1
    Apache doesn't redirect when you use ServerAlias. This directive means just that - it's an alias name for the same VirtualHost block. If you're being redirected, it's the software you're running from Apache doing it, not Apache itself. For example, WordPress is very finnicky over what domain is used to access it, for SEO reasons, and will aggresively redirect you if you don't access it via the domain name in its configuration. – dannosaur Jul 21 '18 at 16:12
  • 1
    So strictly speaking, with any other complicating factors aside (as you mention), using an "alias" does, in fact, let you keep that other domain as the one the user is going to see, yes? – Brainy Smurf Jul 21 '18 at 16:23
  • That is correct. – dannosaur Jul 21 '18 at 18:48
  • Your problem is not at the DNS level, and DNS ALIAS records won't help. The apache ServerAlias is also fine. Your apache is somewhere configured to send a redirect. – RalfFriedl Jul 22 '18 at 0:29

I believe you can achieve this using URL rewrite in Apache

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.