URL重写IIS 7.0上带子域的问题,IIS 7.5中不存在 [英] URL Rewrite issues on IIS 7.0 with subdomains, not present on IIS 7.5
问题描述
我正在构建这个需要几个子域的asp.net应用程序。它们将共享相同的代码库,但我在其自己的子文件夹中为每个子域分别使用.aspx,如下所示:
i'm building this asp.net application that require couple of subdomains. they will all share the same code base but i have separate .aspx for each subdomain in its own subfolder, as follows:
admin.domain.com -> domain.com/admin
user.domain.com -> domain.com/user
...
我的开发箱上的一切都很棒(win7 ,iis 7.5)使用以下重写规则:
everything works great on my dev box (win7, iis 7.5) using the following rewrite rules:
<rule name="admin.domain.com" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^admin.domain.com$" />
<add input="{PATH_INFO}" pattern="^/images/" negate="true" />
<add input="{PATH_INFO}" pattern="^/handlers/" negate="true" />
<add input="{PATH_INFO}" pattern="^/aspnet_client/" negate="true" />
<add input="{PATH_INFO}" pattern="^/webservices/" negate="true" />
<add input="{URL}" pattern="\.axd$" negate="true" />
</conditions>
<action type="Rewrite" url="\admin\{R:0}" />
</rule>
当我将我的版本推送到运行Win 2008 R1的生产时,在IIS 7.0上重写中断。我看到页面来源中的< form>
标记指向 action =admin /
,而在7.5它指向root。因此,当我发布我的表单时,我会得到404,因为每次重写都没有/ admin子文件夹。
When i push my release over to production, which runs Win 2008 R1, on IIS 7.0 the rewrites break. I see that my <form>
tag in source of the page points to action="admin/"
, whereas on 7.5 it points to root. So when i post my forms i get 404s, as there is no /admin subfolder per rewrites.
我有什么办法可以解决这个问题吗?我想省略升级到R2只是为了解决这个问题。我可以单独升级URL Rewrite模块吗?我可以使用不同的重写规则修复此问题吗?
Is there anything i can do to remedy this? I would like to omit upgrading to R2 just to fix this. Can i upgrade URL Rewrite module alone? Can i fix this using different rewrite rule?
感谢任何帮助!
推荐答案
我找到了一个解决方案,出于某些原因在iis 7.0上,你必须在你定义表单的地方添加以下内容。在我的情况下,它是我的母版页中的Page_Load。希望这可以帮助。
i found a solution, for some reason on iis 7.0 you must add the following where you have your form defined. in my case it was a Page_Load within my master page. hope this helps.
form1.Action = Request.RawUrl
这篇关于URL重写IIS 7.0上带子域的问题,IIS 7.5中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!