What I want to do is the following:

My domain xy.example.com no longer exists. Thus I want to do a simple redirect to the new domain abc.example.com. It should be a redirect, that also works when someone types in the browser bar http://xy.example.com/team.php - than it shoul redirect to http://abc.example.com/team.php

I've already tried a few things, but it didn't really work. What do I have to put in the Apache 2 config?

  • 3
    A late comment. if xy.example.com does not exist anymore meaning there is no ip-adress for xy.example.com, nobody will go anywhere when they type that in the browser. The domain must exist before anyone can go there to be redirected. It's like putting a physical answering machine on your old telephone line giving your new number, then disconnecting the line. – Lenne Jan 7 '16 at 9:37
  • For ISPConfig redirect, see howtoforge.com/community/threads/… – Fernando Kosh Mar 22 at 3:12

You can use the RedirectPermanent directive to redirect the client to your new URL.

Just create a very simple VirtualHost for the old domain in which you redirect it to the new domain:

<VirtualHost *:80>
    ServerName xy.example.com
    RedirectPermanent / http://abc.example.com/
    # optionally add an AccessLog directive for
    # logging the requests and do some statistics

Create or edit a .htaccess inside your DocumentRoot. Add

RewriteEngine On
RewriteRule ^(.*)$ http://abc.example.com/$1 [R=301,L]

Additionally I would change the ServerName directive to the new domain and leave a ServerAlias with the old domain.

ServerName abc.example.com
ServerAlias xy.example.com
  • 1
    I cant see how this would work on its own. A RedirectCond !^xy.example.com$ is required to prevent a forwarding loop. – GeoSword Nov 20 '18 at 12:00

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.