How to Redirect any subdomain request to main domain in asp.net

前端 未结 2 1689
长情又很酷
长情又很酷 2021-01-23 01:06

I\'m trying to redirect all subdomain requests for domain.com to www.domain.com and user must access all part of website only by enter to main domain and click on links , for ex

2条回答
  •  花落未央
    2021-01-23 01:23

    Using the URL Rewriting module could be the way to go. Try using configuration similar to the following:

    
        
            
                
                
                    
                    
                        
                    
                    
                
            
        
    
    

    This will redirect without showing an error page. If you want to show an error page then you'll need to redirect to a page that takes the return URL and does a client-side redirect to the right place.

    As @inspile says you're going to have trouble doing it for sub-pages of the site. You may be able to do it using the referer to make sure it's from a link on the main site. Again the URL Rewrite module is the way to go here.

    Cheers

提交回复
热议问题