How to redirect HTML pages? [ Solved ]

4/22/2019 9:47:50 AM

>> V R T <<

10 Answers

New Answer


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.


SEO specialists reccommend in .htaccess


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>


Thanks clab02 for the answer. I found an alternate using JavaScript window.location.href = "https://example.com"


you can redirect in js using: window.location="https://yoursite.com";


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);


You can redirect the server side page (like aspx) and the HTML page will follow suit 😎


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


<!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>