Security, Tech & Programming
Redirect CheatSheet

Redirect CheatSheet

This page lists methods to redirect a webpage using various technologies.

How to redirect webpage using PHP

// make sure that there is no page output before this code
header('Location: https://example.com');

How to redirect webpage using JavaScript

// Simulate a mouse click:
window.location = "https://example.com";
window.location.assign("https://example.com");
window.location.href = "https://example.com";

// Simulate an HTTP redirect:
// (meddles with history & go back ability)
window.location.replace("https://example.com");

How to redirect using on webpage using html meta http-equiv

<!-- 30 is number of seconds to wait -->
<meta http-equiv="refresh" content="30, url=https://example.com">

<!-- to simply refresh current page: -->
<meta http-equiv="refresh" content="30">

Leave a Reply

Your email address will not be published. Required fields are marked *

Hire Me!