Question:
How to redirect one page URL to another page URL by JavaScript?
Solution:
We can use PHP for redirecting one page to another. But it is simple to redirect multiple url redirection from one URL to other URL by JavaScript easily.
See the Simple pseudo code of javascript page redirection,
<script>
if(window.location.href == 'old_url')
{
window.location.href="new_url";
}
//More url's redirect
if(window.location.href == 'old_url2')
{
window.location.href="new_url2";
}
</script>
And real life example for that is:
<script>
if(window.location.href == 'https://test.com')
{
window.location.href="https://another.com";}
//More url's redirect
if(window.location.href == 'https://test.com/new-post')
{
window.location.href="https://another.com/duplicate-post";}
</script>
Tags: Website redirect by javascript, Website redirects, Redirection of a site, How to redirect one page URL to another page URL by JavaScript, How to redirect one page to another page by javascript, Blogger page redirect, how to redirect a blogger page to another page, redirect html page, how to redirect html site to another site, how to redirect one site to another site