URL Rewrite Module Configuration Reference

Accessing URL Parts from a Rewrite Rule

It is important to understand how certain parts of the URL string can be accessed from a rewrite rule.

For an HTTP URL in this form: http(s)://<host>:<port>/<path>?<querystring>

  • The <path> is matched against the pattern of the rule.
  • The <querystring> is available in the server variable called QUERY_STRING and can be accessed by using a condition within a rule.
  • The <host> is available in the server variable HTTP_HOST and can be accessed by using a condition within a rule.
  • The <port> is available in the server variable SERVER_PORT and can be accessed by using a condition within a rule.
  • Server variables SERVER_PORT_SECURE and HTTPS can be used to determine if a secure connection was used. These server variables can be accessed by using a condition within a rule.
  • The server variable REQUEST_URI can be used to access the entire requested URL path, including the query string.

For example, if a request was made for this URL: http://www.mysite.com/content/default.aspx?tabid=2&subtabid=3, and a rewrite rule was defined on the site level then:

  • The rule pattern gets the URL string content/default.aspx as an input.
  • The QUERY_STRING server variable contains tabid=2&subtabid=3.
  • The HTTP_HOST server variable contains www.mysite.com.
  • The SERVER_PORT server variable contains 80.
  • The SERVER_PORT_SECURE server variable contains 0 and HTTPS contains OFF.
  • The REQUEST_URI server variable contains /content/default.aspx?tabid=2&subtabid=3.
  • The PATH_INFO server variable contains /content/default.aspx.

Note that the input URL string passed to a distributed rule is always relative to the location of the Web.config file where the rule is defined. For example, if a request is made for http://www.mysite.com/content/default.aspx?tabid=2&subtabid=3, and a rewrite rule is defined in the /content directory, then the rule gets this URL string default.aspx as an input.

 

https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference

转载于:https://www.cnblogs.com/lizhanglong/p/7940309.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值