URL Rewrite issues on IIS 7.0 with subdomains, not present on IIS 7.5

◇◆丶佛笑我妖孽 提交于 2019-12-25 08:47:38

问题


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
...

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>

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.

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?

Any help is appreciated!


回答1:


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


来源:https://stackoverflow.com/questions/6698246/url-rewrite-issues-on-iis-7-0-with-subdomains-not-present-on-iis-7-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!