Redirect User to Different Domain without Loosing Website Traffic

580 views 1 minutes read
A+A-
Reset

Hi,

Recently, I have changed my Blog address. Due to this, I have to face a lot of Traffic Loss.

My situation was, I have a Blogger blog and a domain. A lot of Links have been shared and If I change the Blog address and create a Permanent Redirect by changing DNS, but existing Bookmarks and Shared Links will not load properly. So, I kept the Existing Domain running and created a New Blog. Exported Template and Blog, Uploaded both to New Domain and just keep both domain running up. Now I have to redirect all visitors to Previous Domain to New Domain. So that website traffic coming from shared links should be alive and must work.

Redirect User to Different Domain without Loosing Website Traffic 2
Here I came with a solution.

I have created a Simple JavaScript function.
[javascript]

function redirect()
{
//You change your Domain name just in place of “//www.pyarb.com”.
window.location = “//www.pyarb.com/” + window.location.pathname;
}

[/javascript]
Description:

1. windows.location – This will set the Location of Window (i.e. Address of Browser.)
2. “//www.pyarb.com” – This is your New Domain. Where you have kept all File structure same. Means Links are same for All files except Domain Name.
3. windows.location.pathname – This will get the Path of Window Location (i.e. Address of Browser except Domain Name.)

Then Executed this function on PageLoad event.
[html]
……
…….

………
………
[/html]

That’s It. Your location remains same.

Enjoy,
+John Bhatt 

 

Related Posts

Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.