I have 3 domains, for the same web app, since I don’t want to have duplicated content I want to redirect the other two domains to the primary domain.
If a user types client_xyz.domain2.com it should be redirected to client_xyz.primarydomain.com.
If a user types client_xyz.domain2.com/folder/file/etc it should be redirected to client_xyz.primarydomain.com/folder/file/etc.
If a user types domain2.com/test/page it should be redirected to primarydomain.com/test/page
I thought this is the best solution to avoid Google penalty for duplicated content.
If you think there’s a better solution to deal with this (eg. DNS), let me know.
Put this code in your .htaccess file: