0

I have two domain names pointing to my server. I want them both to serve identical HTML. I thought I would just do the following, however, it was unsuccessful. Note that I eventually will want ssl 443 to act similarly.

How do I make any requests to mydomain.net display HTML from mydomain.com?

Thank you

<VirtualHost *:80>
  ServerName mydomain.net
  RewriteEngine on
  RewriteRule mydomain.net mydomain.com [PT]
</VirtualHost>

<VirtualHost *:80>
  ServerName mydomain.com
  ...
  a bunch of stuff
  ...
</VirtualHost>
1

Use this VirtualHost configuration instead of the one in your question:

<VirtualHost *:80>
  ServerName mydomain.com
  ServerAlias mydomain.net
  ...
  a bunch of stuff
  ...
</VirtualHost>
| improve this answer | |
  • Thanks Tero, but I don't believe this is an option as I have other websites hosted on the server, and need to use virtual hosts. I know that rewriting is a possibility, but just don't know how to do it. – user1032531 May 9 '14 at 2:18
  • I meant the first VirtualHost section you had in your question. You can leave your other VirtualHosts as is. The ServerAlias directive makes Apache serve the same HTML content to both mydomain.net and mydomain.com. – Tero Kilkanen May 9 '14 at 2:22
  • Ah, I didn't originally understand. So, I put ServerAlias mydomain.net in another the VirtualHost directory? – user1032531 May 9 '14 at 2:30
  • I have edited my answer with more clear example. – Tero Kilkanen May 9 '14 at 2:34
  • Thanks Tero, Works perfectly. I really didn't expect it to work as I thought I needed to rewrite, and was pleasantly surprised! – user1032531 May 9 '14 at 2:49

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.