如何使用IIS7 URL Rewrite 2.0在WinHost上管理子域? [英] How to manage sub-domains on WinHost with IIS7 URL Rewrite 2.0?

查看:60
本文介绍了如何使用IIS7 URL Rewrite 2.0在WinHost上管理子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试 WinHost ,而子域出现了一些问题.在WinHost上,每个主机帐户可以有多个子域,但是每个子域都指向根网站.例如.您可以拥有www.example.com,sub1.example.com和sub2.example.com,但它们都将内容显示在

I'm trying out WinHost and I'm running into some issues with sub-domains. On WinHost, you can have multiple sub-domains per hosting account, but each sub-domain points to the root website. E.g. you can have www.example.com, sub1.example.com, and sub2.example.com but all of them display the content at http://www.example.com/.

其他主机允许您将子域指向网站中的子文件夹.这将允许您将sub1.example.com指向/sub1,将sub2.example.com指向/sub2,将www.example.com指向/.

Other Hosts allow you to point sub-domains to a sub folder in your website. This would allow you to point sub1.example.com to /sub1, sub2.example.com to /sub2 and www.example.com to /.

WinHost建议使用 asp/aspx页面 http://sub1.example.com 重定向到 http://sub1.example.com/sub1 ,它指向/sub1.虽然可以,但是我不想在URL中两次都没有子域.

WinHost recommends using an asp/aspx page to redirect http://sub1.example.com to http://sub1.example.com/sub1, which points to /sub1. While that would work, I'd like to not have the subdomain in the url twice.

所以我尝试使用IIS7 URL重写将 http://sub1.example.com 指向/sub1 .本·鲍威尔(Ben Powell)在他的详细描述中博客.很好,除了Request.ApplicationPath现在是/sub1/path/to/current/page.aspx,它破坏了ASP.Net主题(也可能破坏了其他东西).

So I tried using IIS7 URL Rewrite to point http://sub1.example.com to /sub1. Ben Powell describes this in detail on his blog. This is great, except Request.ApplicationPath is now /sub1/path/to/current/page.aspx, which breaks ASP.Net Themes (and probably other stuff too).

我该怎么做才能修复ApplicationPath?有没有更好的方法可以做到这一点?

What can I do to fix the ApplicationPath? Is there a better way to accomplish this?

推荐答案

我在serverfault上遇到了麻烦.那里也没有有用的答案,但我确实发布了解决方案:

I tried my luck on serverfault. No helpful answers there either, but I did post my solution:

我不知道如何解决 应用程序路径,所以现在我只是 使用URL重写模块来 重定向(不重写) http://sub.example.com/abchttp://sub.example.com/sub/abc.它是 不理想,但可以.看我的博客 详细信息.

I couldn't figure out how to fix the application path, so now I'm simply using the URL Rewrite Module to redirect (not rewrite) from http://sub.example.com/abc to http://sub.example.com/sub/abc. It's not ideal, but it works. See my blog post for the details.

https://serverfault.com/questions/134125/how-to-manage-sub-domains-on-winhost-with-iis7-url-rewrite-2-0/135533#135533

这篇关于如何使用IIS7 URL Rewrite 2.0在WinHost上管理子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆