301跳转必须由程序或服务器来实现,如果是页面跳转可以使用js或页面html来实现,下面我们先来介绍页面跳转,然后再介绍301跳转了.
一般情况下,此类跳转是302跳转,只是暂时性跳转,如果需要进行永久重写向(SEO上比较有用),可如下实现:
header("HTTP/1.1 301 Moved Permanently");
header("Location: redirect.php");
平时我们使用html做页面的时候,都会碰到定时刷新,可以看到如下标签:
表示每隔两秒刷新一次页面,实际上是重定向到页面。
由此,PHP根据HTTP协议,可以如下实现:
header( "refresh:2;url=refresh.php" );
1.window.location.href方式
2.window.navigate方式跳转
3.window.loction.replace方式实现页面跳转,注意跟第一种方式的区别
有3个jsp页面(1.aspx, 2.aspx, 3.aspx),进系统默认的是1.aspx,当我进入2.aspx的时候, 2.aspx里面用window.location.replace("3.aspx");
与用window.location.href ("3.aspx");
从用户界面来看是没有什么区别的,但是当3.aspx页面有一个"返回"按钮,调用window.history.go(-1); wondow.history.back();方法的时候,一点这个返回按钮就要返回2.aspx页面的话,区别就出来了,当用 window.location.replace("3.aspx");连到3.aspx页面的话,3.aspx页面中的调用 window.history.go(-1);wondow.history.back();方法是不好用的,会返回到1.aspx。
4.self.location方式实现页面跳转,和下面的top.location有小小区别
5.top.location

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools