Awesome q2a theme
I want to automatically redirect a Web Page to another URL. That is when a visitor comes to the old URL he will be automatically redirected to the new URL.
The short answer

You can automatically redirect a web page to another URL using either HTML meta tags or JavaScript. Here's how to do it using both methods: 1.

You can automatically redirect a web page to another URL using either HTML meta tags or JavaScript. Here's how to do it using both methods:

1. HTML Meta Tag Redirect:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="refresh" content="5;url=https://www.example.com"> <title>Redirecting...</title> </head> <body> <p>This page has moved to <a href="https://www.example.com">example.com</a>.</p> <p>If you are not redirected automatically, <a href="https://www.example.com">click here</a>.</p> </body> </html>

  • In the <meta http-equiv="refresh" content="5;url=https://www.example.com"> line, content="5; means the page will redirect after 5 seconds. You can adjust the number according to your preference.
  • Replace https://www.example.com with the URL you want to redirect to.

JavaScript Redirect:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="refresh" content="5;url=https://www.example.com"> <title>Redirecting...</title> <script> window.onload = function() { setTimeout(function() { window.location.href = "https://www.example.com"; }, 5000); // 5000 milliseconds = 5 seconds }; </script> </head> <body> <p>This page has moved to <a href="https://www.example.com">example.com</a>.</p> <p>If you are not redirected automatically, <a href="https://www.example.com">click here</a>.</p> </body> </html>

  • In the JavaScript code, window.location.href = "https://www.example.com"; redirects the page to the specified URL after 5 seconds (5000 milliseconds).
  • You can adjust the timing by changing the value in setTimeout().
Last updated May 20, 2024
Was this helpful?
0 votes

This page has moved to example.com.

If you are not redirected automatically, click here.

In the JavaScript code, window.location.href = \" https://www.example.com \"; redirects the page to the specified URL after 5 seconds (5000 milliseconds). You can adjust the timing by changing the value in setTimeout().","url":"https://mommya.com/47/how-to-automatically-redirect-a-web-page-to-another-url#a64","dateCreated":"2024-05-20T19:16:45+00:00","author":{"@type":"Person","name":"Sarah","url":"https://mommya.com/user/Sarah"}},"text":"I want to automatically redirect a Web Page to another URL. That is when a visitor comes to the old URL he will be automatically redirected to the new URL.","dateCreated":"2022-12-28T14:58:09+00:00"}}
58 questions
58 answers
7 users