Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-redirect to another HTML page

Tags:

html

What is the syntax for making a page auto-redirect to a different HTML file in a separate folder? All of my searching returns how to redirect from one website to another.

like image 762
Hingle Mcringleberry Avatar asked Jan 12 '15 04:01

Hingle Mcringleberry


People also ask

How do I automatically redirect from one website to another?

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 the user to the new web page. To redirect immediately, set this parameter to “0” seconds for the content attribute.

How do you redirect to another page in HTML After submit?

If you want to redirect to another page after form submit html, Then you have to provide/Sign the Other pages path inside HTML Form tag's ACTION Attribute. Which will POST/Send your Form data to that Location and Open/Redirect your Users to That Given Web Page.

Is used to redirect to another page?

Approach: To redirect from an HTML page to another page, you can use the <meta> tag by specifying the particular link in the URL attribute. It is the client-side redirection, the browsers request the server to provide another page.

What is auto redirection?

Auto-Redirects--A Stealth Attack With Lasting Effect The user opens a publisher site in a browser window. Malicious code is deployed through an unsecured ad slot. A pop-up appears, covering the page's content–or, if it's on mobile, covering most of the screen.


4 Answers

One of these will work...

<head>
  <meta http-equiv='refresh' content='0; URL=http://example.com/'>
</head>

...or it can done with JavaScript:

window.location.href = 'https://example.com/';
like image 175
Prashant Shastri Avatar answered Oct 16 '22 23:10

Prashant Shastri


<meta http-equiv="refresh" content="5; url=http://example.com/">

like image 45
Rafael Avatar answered Oct 17 '22 00:10

Rafael


If you're using Apache and can use a .htaccess file you should use the following type of redirect. Add the following to an .htaccess file in the root of your website.

RewriteEngine On
RewriteRule ^/oldfile_path/file_name\.html$ /oldfile_path/file_name.html [R=301,L]

This has the advantage of being a very fast and immediate redirect. It also depends on your reason for the redirect. This is a more permanent method because it sends the HTTP 301 status code signifying that the file has moved permanently and causes many browsers to cache that request. You can change the code to something else like a 302 for temporary redirects.

Otherwise you can do a simple redirect using an HTML <meta> tag as suggested by others:

<meta http-equiv="refresh" content="5; url=http://example.com/">

By default the content="5" makes that redirect after 5 seconds. This will be slower and not all browsers support it. A redirect can also be done in the server language of your choice PHP, Node.js, etc.

like image 11
Ding Avatar answered Oct 16 '22 23:10

Ding


You can use <meta> tag refresh, and <meta> tag in <head> section

<META http-equiv="refresh" content="5;URL=your_url"> 
like image 8
Girish Avatar answered Oct 17 '22 00:10

Girish