Redirect domain to another domain

0
69

Many people who deal with web design, and even hosting, sometimes have to redirect some domain to another domain.
If you do not use the so-called “all inclusive” web control panels which make all these things super easy, such as cPanel, you are wondering, or you have already wondered how to redirect the domain to another.
It doesn’t matter which DNS panel you use, there is a procedure that you simply have to follow.
STEP 1: To redirect domain X to domain Y, in the DNS panel of domain X add just one record:

  • create an “A” record that directs the X domain to IP server address where the Y domain is located.

Then on the that server (where the Y domain is hosted), add that the X domain as an alias to the Y domain.
Then wait a few minutes and that’s it.

STEP 2: If you use Moss there’s nothing to worry about, just click New alias in the domain tab of your site and fill out the form.
https://moss.sh/docs/managing-sites/add-domain-names-to-your-website/

domain alias

If by any chance you use Server Pilot or similar cloud panel, the things are a bit more complicated:
You should add the X domain as a new website and then in its root folder create a .htaccess file in your app’s web root directory:

public/.htaccess

with the following contents:

RewriteCond %{HTTP_HOST} =OLDDOMAIN
RewriteRule (.*) http://NEWDOMAIN/$1 [R=302,L]

OR
Just redirect everything with this:

RewriteRule (.*) http://example.com/$1 [R=302,L]

All in all, I use Moss, you should too.

You can read more about the 301/302 redirects on Serverpilot:
https://serverpilot.io/docs/how-to-redirect-to-a-different-domain/

Leave a reply

Please enter your comment!
Please enter your name here