HTML is a language used to build web pages. Web pages have a dynamic nature where it can change during time. One of the most popular change cases is redirecting a given web page to another web page. This is simply called a web page redirect. In this tutorial, we will examine the redirect process in different ways, languages, and technologies.
HTML是用于构建网页的语言。 网页具有动态性质,可以随时间变化。 最受欢迎的变更案例之一是将给定的网页重定向到另一个网页。 这简称为网页重定向。 在本教程中,我们将以不同的方式,语言和技术检查重定向过程。
HTML重定向 (HTML Redirect)
The most popular and basic for web page redirect is using HTML. HTML has two main parts named <head>
and <body>
. We can provide some special tags into <head>
in order to redirect the HTML page. We will use <meta>
tag with detailed attributes. In this example, we will redirect to https://www.poftut.com
. We will use http-equiv
attribute with refresh
value.
网页重定向最流行和最基本的方法是使用HTML。 HTML有两个主要部分,分别名为<head>
和<body>
。 我们可以在<head>
中提供一些特殊的标签,以便重定向HTML页面。 我们将使用具有详细属性的<meta>
标记。 在此示例中,我们将重定向到https://www.poftut.com
。 我们将使用带有refresh
值的http-equiv
属性。
<meta http-equiv="refresh" content="0; URL='https://poftut.com'" />
JavaScript重定向 (JavaScript Redirect)
JavaScript is a client-side technology that can make dynamic changes after or during HTML page load. JavaScript language provides window.location
object which is used to get and set the current page URL.
JavaScript是一种客户端技术,可以在HTML页面加载之后或加载过程中进行动态更改。 JavaScript语言提供了window.location
对象,该对象用于获取和设置当前页面的URL。
windows.location="https://www.poftut.com";
OR JavaScript provides different mechanisms to change or redirect HTML web page.
或JavaScript提供了不同的机制来更改或重定向HTML网页。
windows.location="https://www.poftut.com";
windows.location.href="https://www.poftut.com";
windows.location.assign("https://www.poftut.com");
windows.location.replace("https://www.poftut.com");
Apache重定向 (Apache Redirect)
Apache is a popular web server. We can redirect a page by using Apache on the server-side. We can use Redirect
or RedirectMatch
directives to redirect web pages completely or specifically.
Apache是流行的Web服务器。 我们可以通过在服务器端使用Apache来重定向页面。 我们可以使用Redirect
或