Auto-redirecting my site using Meta tag
There might be many reasons you would like to use this functionality of auto-loading another website from your own webpage.
- You might want to redirect your site to another site on load
- Embed a full screen iframe of an external site
- You got an old website and want to divert your traffic to a new site
There are many ways to do this. like using
window.location.href= 'https://google.com';
This reloads the page as soon as the statement is being called. But the most simplest and easiest way I found without using JavaScript is using meta tag.
Sample code:
<html xmlns=”http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=”refresh” content=”0;URL=’http://google.com/'" />
</head>
<body>
</body>
</html>
meta
element with the value of the http-equiv
attribute set to "Refresh
" and the value of the content
attribute set to "0" (meaning zero seconds), followed by the URI that the browser should request will do the job. It is important that the time-out is set to zero, to avoid that content is displayed before the new page is loaded. The page containing the redirect code should only contain information related to the redirect.
But if you want to display a message that your webpage is moved to another URL then you can set the content
attribute to, say ‘10’ seconds and display a message <p>This page has moved to <a href="https://example.com/">
in the body so that user can even click on the link even before auto-refresh.
here</a>.</p>
Hope this helps!