Table of Contents
1. 定义
2. 作用
3. 分类
4. 实现
Home Web Front-end HTML Tutorial Server redirection and client redirection learning, analysis and implementation_html/css_WEB-ITnose

Server redirection and client redirection learning, analysis and implementation_html/css_WEB-ITnose

Jun 24, 2016 am 11:55 AM

1. 定义

网域名称转址(英语:URL redirection,或称网址重定向或URL重定向),是指当用户浏览某个网址时,将他导向到另一个网址的技术

2. 作用

  1. 相似域名

  2. 网站迁移至新域名

  3. 记录外送链接

    例:QQ邮箱中点击邮件链接是的警告其实服务器在收到邮件时就以做了处理

  4. 简化网址

    例:微博中的附加链接

3. 分类

  1. 服务器端跳转(forward跳转)

    1. 原理

    用户 请求 -> 原服务器 请求 -> 资源服务器 响应 -> 用户

    1. 特点
  2. 重定向后用户的URL没发生任何变化

  3. 只能进行站点内跳转

  4. 根目录代表服务器跟路径webapps

  5. request设置的属性在跳转后的页面仍可以使用

  6. 使用 传递参数

  7. 执行到跳转语句后马上无条件跳转,之后的代码不再执行(跳转之前一定要释放全部资源)

  8. 客户端跳转(response跳转)

    1. 原理

    用户 请求 -> 原服务器 响应 -> 用户 请求 -> 资源服务器 响应 -> 用户

    1. 特点
  9. URL变为重定向后所请求的URL

  10. 可以进行站外跳转

  11. 根目录代表站点根路径

  12. 跳转后的页面不能使用上一个页面的request属性

  13. 使用地址重写传递参数(response.sendRedirect("URL?参数名=参数值"))

  14. 所有代码执行完毕后跳转

4. 实现

  1. PHP
<?phpheader('HTTP/1.1 301 Moved Permanently');header('Location: http://www.example.com/');exit();
Copy after login
<?phpheader( 'Refresh: 0; url=http://www.example.com/' );exit();
Copy after login
  1. Apache HTTP Server's mod_alias extension
Redirect permanent /oldpage.html http://www.example.com/newpage.htmlRedirect 301 /oldpage.html http://www.example.com/newpage.html
Copy after login
  1. Apache mod_rewrite
RewriteEngine onRewriteCond %{HTTP_HOST} ^([^.:]+\.)*oldsite\.example\.com\.?(:[0-9]*)?$ [NC]RewriteRule ^(.*)$ http://newsite.example.net/$1 [R=301,L]
Copy after login
  1. HTML的Refresh Meta tag and HTTP refresh header
<html>    <head>        <meta http-equiv="Refresh" content="0; url=http://www.example.com/" />    </head>    <body>    </body></html>
Copy after login
  1. HTML的Frame redirects
<html>    <frameset rows="100%">      <frame src="http://www.example.com/">    </frameset></html>
Copy after login
  1. JavaScript redirects
window.location='http://www.example.com/';
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

See all articles