Microsoft rewriting module - Force www on url Or remove www from url

后端 未结 1 427
囚心锁ツ
囚心锁ツ 2020-12-24 08:46

I have a shared hosting plan with Windows Server 2008 and IIS7.5, and there is Microsoft rewriting module installed and enabled.


    

        
1条回答
  •  不思量自难忘°
    2020-12-24 09:14

    To remove the www from a domain and redirect to a "naked domain" you could di it like in the following code snippet:

    
      
        
          
          
            
          
          
        
      
    
    

    And the other way around (if you prefer that) to redirect a non-www to one with www:

    
      
        
          
          
            
          
          
        
      
    
    

    The redirectType="Permanent" is of course optional but for SEO and most scenarios I would recommend it.

    Please see also these SO questions/answers:

    • IIS7 URL Rewrite - Add "www" prefix
    • Forwarding http://mydomain.com/ctrlr/act/val to http://WWW.mydomain.com/ctrlr/act/val
    • Proper method to remove www from address using IIS URL Rewrite

    0 讨论(0)
提交回复
热议问题