获取域的子域 [英] Getting domain from subdomain
问题描述
我得到的网址
http://orders.mealsandyou.com/default.php
我不希望使用字符串函数用它来让主域即
i dont want to use string functions to use it to get the main domain ie
mealsandyou.com
mealsandyou.com
有没有在C#中的任何功能,要做到这一点,UrilAuthority和所有给子域太...
is there any function in c# to do that, UrilAuthority and all gives subdomain too...
建议表示欢迎,而不是解决方法
Suggestions welcome, not workarounds
推荐答案
域字符串的唯一不变的部分是TLD。该顶级域名是域名字符串,如.COM,.NET,.UK等等一切都在那其他依赖于它的位置,特别是顶级域名的最后位(所以你不能假设倒数第二个部分是域名一样,为.co.uk将它.CO。
The only constant part of the domain string is the TLD. The TLD is the very last bit of the domain string, eg .com, .net, .uk etc. Everything else under that depends on the particular TLD for its position (so you can't assume the next to last part is the "domain name" as, for .co.uk it would be .co.
在我觉得你采取错误的做法无论如何。 URL重写是更适合这样的事情。有这样一个阅读:learn.iis.net/page.aspx/460/using-the-url-rewrite-module
In any case I think you're taking the wrong approach. URL rewriting is far more suited to this sort of thing. Have a read of this: learn.iis.net/page.aspx/460/using-the-url-rewrite-module
这篇关于获取域的子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!