Redirect subdomain and all pages to main domain

Redirect subdomain and all pages to main domain

Redirect:

When it comes to redirect your existing site to another domain there are lots of options available by which you can make it happen like configuring Server Namespace, Redirect Domain, using Scripts etc. But what if you want your subdomain to be moved on your new domain without loosing your followers?

I recently came across in a situation where I was working on my old blogger which I created on a sub domain and was blogging since last 2-3 years. The blog gone well on google and I decided to move it to the main domain to make more visible and attractive and definitely public attentive. After doing lots of Google and research I made it happen that I would like to share with you. The given scenarios is based on GoDaddy as my hosting was in GoDaddy hence some UI or look may change based on your hosting provider but less or more on all hosting providers the steps are same so don’t worry.

Step 1 – Enabling Redirect:

Login to your hosting cPanel where your subdomain is kept and navigate to “Redirect” section as shown below:

Step 2- Configuration:

  • Type: Keep it 301 which refers to permanent redirection
  • ** All Public Domain **: You need to select your sub domain from the dropdown
  • / : this is the main game changer field, Hence you need to put your subdomain directory name here which you can find under your public_html directory
  • Redirects to: Provide your destination or new domain that your want to point

Once above settings are done make sure you check on “wild card redirect” checkbox and click on ADD button.

Step 3– change .htaccess file:

To achieve complete redirect where your subdomain comes under Google search by pointing specific post or page should redirect to your new domain with same post or page, we need to make some changes in .htaccess file which you can locate within your subdomain directory:

It will look like above under your File Manager in cPanel. Open it in edit mode and put following script at the end to make sure redirect works:

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteRule ^(.*)$ https://newDomain.com/$1 [R=301,L]
</IfModule>

Note: Above script can be vary based on Site architecture, I have done it for WordPress site.

That’s it you are done. Please leave your comments

Leave a Reply

Your email address will not be published.