IIS重定向和重写之间的区别(与重定向有关) [英] Difference between IIS Redirect and Rewrite (in relation to redirecting)

查看:344
本文介绍了IIS重定向和重写之间的区别(与重定向有关)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题听起来很奇怪,但是给出了

The question may sound odd, but given an article, it is definitely possible to use the rewrite module to perform redirects just as with the redirect module. Both are able to issue a permanent redirect (301).

有一个问题要求区别,但它讨论的是重写模块仅用于 rewrite 而不是 redirect .另一个帖子弄清楚了,但似乎没有得到足够的答案.

There is a question asking for the difference, but it talks about the rewrite module being used to purely rewrite not redirect. Another post makes this clear, but doesn't seem to get an adequate answer.

因此,我的问题是:这些模块之间有什么区别?重定向时,哪一种优先于另一种?

Hence, my question: What's the difference between these modules? Which is preferred over the other when it comes to redirects?

推荐答案

注意:该答案不能回答IIS重定向(httpRedirect)与URL重写模块的Redirect之间的差异,而是URL重写模块的(重定向与重写)之间的差异).

如果您尝试将复杂的URL(带有查询字符串)隐藏为更友好的URL,则必须采用重写方法,因为浏览器/搜索引擎将始终看到200OK,并假定内容来自请求的原始URL.

If you are trying to hide complex URL (with querystrings) to more friendly URLs then Rewrite is the way to go as browser/Search Engines will always see 200OK and assume the content is coming from requested original URL.

如果您试图向新的URL的搜索引擎/用户表明资源已发生变化,则重定向是您发送301状态代码的一种方式,该状态代码表明资源已从原始位置转移到了新位置.

If you are trying to indicate a change of resource to search engines/users of new URL then Redirect is the way to go as you are sending 301 status code saying that resource has moved from original to this new location.

IIS重定向:

  • 重定向发生在客户端
  • 浏览器在地址栏中看到另一个URL.
  • 客户端知道重定向URL.
  • 可以发布
  • 301/302.(也可以发布303/307)
  • 对于SEO/搜索引擎可以指示新URL很有用. mysite.com/abc到mysite.com/pqr
  • 可以完全重定向到同一站点或不同站点.
  • Redirecting happens at Client Side
  • Browser sees a different URL In address bar.
  • Client aware of a redirect URL.
  • 301/302 can be issued. (303/307 can be issued too)
  • Good for SEO/Search Engine to indicate of new URL. mysite.com/abc to mysite.com/pqr
  • Can be redirected to same site or different site altogether.

IIS重写:

  • 重定向发生在服务器端
  • 浏览器在地址栏中看不到新的URL.
  • 客户端不知道是否通过重写的URL提供内容.
  • 未发布301/302.假设重写的URL资源可用,则正常情况下会获得200 OK.
  • 很好隐藏不友好的URL和SEO. mysite.com/article/test-sub/至mysite.com/article.aspx?id=test-sub
  • 通常用于同一站点内的资源.

请求处理(重定向):www.mysite.com/abc重定向到www.mysite.com/pqr

Request Handling (REDIRECT): www.mysite.com/abc to redirect to www.mysite.com/pqr

  1. 客户致电:www.mysite.com/abc
  2. URL重写模块看到了与客户端URL匹配的规则,并提供了新的重定向URL.
  3. 服务器使用新URL响应301,以使客户端调用www.mystite.com/pqr
  4. 客户调用新网址www.mystite.com/pqr
  5. 服务器对新URL的响应为200 OK. (地址栏显示新的网址)

请求处理(重写):www.mysite.com/abc,您要指向www.mysite.com/pqr

Request Handling (REWRITE): www.mysite.com/abc which you want to point to www.mysite.com/pqr

  1. 客户致电:www.mysite.com/abc
  2. URL重写模块发现规则匹配项,并向IIS提供了新的重写URL,即www.mysite.com/pqr,服务器在IIS中请求了该URL.
  3. 服务器对原始URL进行200 OK响应,但对重写的URL中的内容进行响应. (地址栏显示原始URL,客户端不知道您正在从其他URL提供内容)

这篇关于IIS重定向和重写之间的区别(与重定向有关)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆