Proper method to remove www from address using IIS URL Rewrite

后端 未结 4 1401
春和景丽
春和景丽 2020-12-01 13:54

What is the optimal way to remove the www subdomain from a url using IIS URL Rewrite?

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 14:37

    If you want it to work with any hostname (not hardcoding it into the rule), you'd want to do something like this:

    
      
      
        
      
      
    
    

    in the redirect action, the {C:1} contains the second capturing group in the condition, whereas the {R:0} contains whatever was in the rule (the path). appendQueryString="true" will also append any querystring to the redirect (if present). Keep in mind though, that any url hashes, if present, will be lost in the process since those don't get passed to the server.

提交回复
热议问题