在 IIS 中将不同的页面作为不同的域名提供服务(6 或 7)

发布于 2024-07-25 03:53:08 字数 588 浏览 2 评论 0原文

我有一个 ASP.Net MVC 应用程序,它为用户页面提供 URL,如 -

www.myapp.com/user/rob/index,
www.myapp.com/user/rob/article/1

www.myapp.com/user/scott/index,
www.myapp.com/user/scott/article/1

现在我希望这个应用程序能够从外部向两个不同的域提供页面。 喜欢 -

www.RobWebSite.com/Index
www.RobWebSite.com/article/1

www.scottBlogSiteNoOne.com/Index
www.ScottBlogSiteNoOne.com/article/1

我需要设置什么样的设置/重定向/代理,以便当用户键入已发布的域名(www.RobWebSite.com)时,它会在内部转换为我的应用程序(www.myapp.com) /用户/抢劫/)。 我想保持浏览器中的 url 与他们输入的内容相同,而只是查询字符串参数发生变化。

谢谢和问候,
阿杰

I have a ASP.Net MVC application which serves user pages with URL like -

www.myapp.com/user/rob/index,
www.myapp.com/user/rob/article/1

and

www.myapp.com/user/scott/index,
www.myapp.com/user/scott/article/1

now I want this one application to serve pages to two different domains from outside. Like -

www.RobWebSite.com/Index
www.RobWebSite.com/article/1

www.scottBlogSiteNoOne.com/Index
www.ScottBlogSiteNoOne.com/article/1

what kind of setup / redirects / proxies I will need to setup so when user types the published domain name (www.RobWebSite.com) it translates internally to my app as (www.myapp.com/user/rob/). I want to keep the url in the browser the same what they typed, while just query string parameters changes.

Thanks and Regards,
Ajay

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终弃我 2024-08-01 03:53:08

每个用户的域名都需要在其 DNS 中指向 myapp.com 的 CNAME 记录。 (Google 使用 CNAME 记录将自定义域名指向 Blogger.com 博客,因此这似乎是一个好方法。)

然后您的代码需要查看 Request 对象来识别正在使用哪个域名并进行查找查找该域属于哪个用户。 这不会真正翻译为 myapp.com/user/name/。 它将使用域名来确定用户,而不是通常使用 MVC 进行的路由解析。

我不能 100% 确定 Request 对象会为您提供正确的域名。 你必须尝试一下。

Each users' domain name will need a CNAME record in their DNS that points to myapp.com. (Google uses CNAME records to point custom domain names to Blogger.com blogs, so that seems like a good way to go.)

Then your code needs to look at the Request object to identify which domain name is being used and do a lookup to find which user the domain belongs to. This wouldn't really be translating to myapp.com/user/name/. It would be using the domain name to determine the user instead of the route parsing that you would normally do with MVC.

I'm not 100% sure that the Request object will give you the right domain name. You'll have to try it out.

痴情换悲伤 2024-08-01 03:53:08

您也可以只设置代码,以便您的 url 指定相对路径而不是绝对 URL。 这将使域名在浏览器中保持相同并提高性能。

You could also just setup your code so that your urls specify relative paths rather than absolute URLs. This will keep the domain name the same in the browser and improve performance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文