+ 13
How to redirect HTML pages? [ Solved ]
10 Antworten
+ 7
You can do this.
<meta http-equiv="refresh" content="0; url=http://example.com/" />
Just place it inside the head tag and put in the url you want to redirect to.
+ 17
SEO specialists reccommend in .htaccess
+ 7
The simplest way to redirect to another URL is to use an HTML <meta> tag with the http-equiv parameter set to “refresh”. The content attribute sets the delay before the browser redirects user to the new web page. For redirect to occur immediately set this parameter to “0” seconds for the contentattribute.
Example
<!DOCTYPE html> <html> <head> <meta http-equiv="Refresh" content="0; url=https://www.w3docs.com" /> </head> </html>
+ 6
you can redirect in js using: window.location="https://yoursite.com";
+ 5
Use
<meta http-equiv="refresh" content="5; url=http://www.google.com " />
*Note the value of the content attribute determines the amount of time ( in seconds) it will take before redirection . The one above will take 5 seconds
+ 4
Thanks clab02 for the answer.
I found an alternate using JavaScript
window.location.href = "https://example.com"
+ 4
You can redirect the server side page (like aspx) and the HTML page will follow suit 😎
+ 2
If you want to show something and then redirect to another webpage
<meta http-equiv="refresh" content="0; URL='http://example.com'" />
Immediate redirect
window.location = "http://example.com";
weird stuff is this works in different versions
window.location.href = "http://example.com";
window.location.assign("http://example.com");
window.location.replace("http://example.com");
if use Apache and have access to .htaccess you can use
Redirect 301 /page.html http://www.example.com/new-page.html
in Php
<?php
header('Location: http://www.example.com');
exit;
?>
in Node.js
var http = require("http");
http.createServer(function(req, res) {
res.writeHead(301,{Location: 'http://example.com'});
res.end();
}).listen(8888);
+ 1
<!DOCTYPE html>
<html>
<head>
<title>HTML Meta Tag</title>
<meta http-equiv = "refresh" content = "2; url = https://www.tutorialspoint.com" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
- 3
gg