Our Blog

Share

301 Redirect: subdomain to TLD

Today I came up with a situation to redirect a subdomain to its TLD. What I was required to do was move the blog from subdomain to top level domain (TLD) and then setup a permanent 301 Redirect from subdomain to TLD. I was having following data:

Subdomain: gopalthorve.com (where currently my wordpress blog is running)

TLD: gopalthorve.com (where I want to shift my wordpress blog to)

Hosting Control Panel: Website Panel

What I did is mentioned below:

  • Download all contents of my wordpress blog from gopalthorve.com using FTP Client
  • Edit wp-config.php and add following two lines at top after <?php and before MySQL Settings section starts

define(‘WP_HOME’,’http://gopalthorve.com’);
define(‘WP_SITEURL’,’http://gopalthorve.com’);

  • Delete all contents of my website running at gopalthorve.com
  • Upload the downloaded contents of gopalthorve.com to gopalthorve.com using FTP Client. I was not required to upload the MySQL database because I am having both sites running under the same hosting space. So, I even didn’t require to edit wp-config.php for MySQL settings. The same settings were going to work for me.
  • Delete all email accounts, mail domain, website related to gopalthorve.com and finally delete gopalthorve.com subdomain itself using Website Panel.
  • Create a Domain Alias in Website Panel to point to existing website gopalthorve.com

After performing above steps I tried to browse for gopalthorve.com, my blog opened up, then I tried to browse for www.gopalthorve.com, www.gopalthorve.com and gopalthorve.com again my blog opened up for each. But what I noticed that when browsing for individual domain and subdomains all come up with the same contents, but the address in address bar of my browse also remains separate for each domain and subdomain please refer the figure below. This is very serious thing from the Search Engine Optimization (SEO) point of view, because I am serving duplicate contents for each domain and subdomain from the search engine point of view which search engines don’t like and affect your website ranking. What I was required to do was that what ever domain or subdomain (gopalthorve.com, www.gopalthorve.com, gopalthorve.com and www.gopalthorve.com) user browse for it should be permanently redirected to either gopalthorve.com or www.gopalthorve.com. I decided to go for gopalthorve.com. It means I need to setup following three 301 Redirect:

301 Redirect : subdomain to TLD

www.gopalthorve.com → gopalthorve.com

gopalthorve.com → gopalthorve.com

www.gopalthorve.com → gopalthorve.com

 

301 Redirect : www.gopalthorve.com to gopalthorve.com

To setup 301 Redirect from www.gopalthorve.com to gopalthorve.com, I added following code in web.config of gopalthorve.com in section <configuration> <system.webServer> <rewrite> <rules>

<rule name="301 Redirect 1" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.gopalthorve.com$" />
</conditions>
<action type="Redirect" url="http://gopalthorve.com/{R:0}" redirectType="Permanent" />
</rule>

301 Redirect : gopalthorve.com to gopalthorve.com

To setup 301 Redirect from gopalthorve.com to gopalthorve.com, I added following code in web.config of gopalthorve.com in followed by the code I added in previous step:

<rule name="301 Redirect 2" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^gopalthorve.com$" />
</conditions>
<action type="Redirect" url="http://gopalthorve.com/{R:0}" redirectType="Permanent" />
</rule>

301 Redirect : www.gopalthorve.com to gopalthorve.com

To setup 301 Redirect from www.gopalthorve.com to gopalthorve.com, I added following code in web.config of gopalthorve.com in followed by the code I added in previous step:

<rule name="301 Redirect 3" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^gopalthorve.com$" />
</conditions>
<action type="Redirect" url="http://gopalthorve.com/{R:0}" redirectType="Permanent" />
</rule>

 

Then I tested for if the above setting works, I browse for www.gopalthorve.com, gopalthorve.com and www.gopalthorve.com, and what I saw was that every time my browsers’ address bar shows gopalthorve.com which means 301 Redirect is setup properly.

Share

Gopal Thorve

8 comments
Sanford Groch
Sanford Groch

I just want to tell you that I am just beginner to blogging and site-building and absolutely enjoyed this page. Probably I’m going to bookmark your blog post . You certainly come with superb articles and reviews. Appreciate it for revealing your web-site.

Gudrun
Gudrun

Nice blog! Is your theme custom made or did you download it from somewhere? A theme like yours with a few simple adjustements would really make my blog stand out. Please let me know where you got your theme. Appreciate it

Gopal Thorve
Gopal Thorve

Thanks for the complement. I use Hybrid News child theme for my blog based on Hybrid Framework. I haven't customize anything except manually modifying style sheet to display logo.

Augusta Naqvi
Augusta Naqvi

I have recently started a web site, the information you offer on this website has helped me greatly. Thank you for all of your time & work.

Mohamed Manzanarez
Mohamed Manzanarez

You got a very great website, Glad I discovered it through yahoo.

Julian Z. Willman
Julian Z. Willman

There may be noticeably a bundle to learn about this. I assume you made certain good points in options also.

Sook Langridge
Sook Langridge

As soon as I observed this internet site I went on reddit to share some of the love with them.

Read more:
Unknown error has occurred – 0x800C0133

Unknown error has occurred - 0x800C0133 0x800C0133 appears in Outlook Express while receiving/downloading email from POP3 email account. This error...

Close