简体   繁体   中英

IIS URL Rewrite for multiple domains

I am very poor with REGEX and need some help. I have multiple domains hosted on one site eg companya.com, companya.cn, companya.fr etc. Based on the host name I would like to redirect them to a subdirectory. So if someone goes to companya.com it would go to companya.com/en-us/default.aspx and if they went to companya.cn it would go to companya.cn/zh-cn/default.aspx.

Can someone help me please come up with a solution?

Thanks

I don't think you'd need a regex for this. You can probably just store country codes in a simple dictionary/hash/whatever it's called in the language you're using. In pseudocode:

country_codes=\
{
    "com":"en-us",\
    "cn":"zh-cn",\
    "fr":"fr-fr"\
    //similar entries for other country codes go here
};
redirect("companya."+tld+"/"+country_codes[tld]+"/default.aspx");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM