如何将HTML网页重定向到另一个URL?

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

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值