


Server redirection and client redirection learning, analysis and implementation_html/css_WEB-ITnose
1. 定义
网域名称转址(英语:URL redirection,或称网址重定向或URL重定向),是指当用户浏览某个网址时,将他导向到另一个网址的技术
2. 作用
相似域名
网站迁移至新域名
-
记录外送链接
例:QQ邮箱中点击邮件链接是的警告其实服务器在收到邮件时就以做了处理
-
简化网址
例:微博中的附加链接
3. 分类
-
服务器端跳转(forward跳转)
- 原理
用户 请求 -> 原服务器 请求 -> 资源服务器 响应 -> 用户
- 特点
重定向后用户的URL没发生任何变化
只能进行站点内跳转
根目录代表服务器跟路径webapps
request设置的属性在跳转后的页面仍可以使用
使用 传递参数
执行到跳转语句后马上无条件跳转,之后的代码不再执行(跳转之前一定要释放全部资源)
-
客户端跳转(response跳转)
- 原理
用户 请求 -> 原服务器 响应 -> 用户 请求 -> 资源服务器 响应 -> 用户
- 特点
URL变为重定向后所请求的URL
可以进行站外跳转
根目录代表站点根路径
跳转后的页面不能使用上一个页面的request属性
使用地址重写传递参数(response.sendRedirect("URL?参数名=参数值"))
所有代码执行完毕后跳转
4. 实现
- PHP
<?phpheader('HTTP/1.1 301 Moved Permanently');header('Location: http://www.example.com/');exit();
<?phpheader( 'Refresh: 0; url=http://www.example.com/' );exit();
- 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
- Apache mod_rewrite
RewriteEngine onRewriteCond %{HTTP_HOST} ^([^.:]+\.)*oldsite\.example\.com\.?(:[0-9]*)?$ [NC]RewriteRule ^(.*)$ http://newsite.example.net/$1 [R=301,L]
- 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>
- HTML的Frame redirects
<html> <frameset rows="100%"> <frame src="http://www.example.com/"> </frameset></html>
- JavaScript redirects
window.location='http://www.example.com/';

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



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

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.

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

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

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

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.

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.

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