重写 IIS 中的子域

发布于 2024-12-10 04:25:32 字数 1857 浏览 0 评论 0原文

我在重写 IIS 中的一些内容时遇到一些问题,

这就是我想要实现的目标。

我们有很多客户都需要子域。例如

http://clientA.mysite.com 需要重写为 http://mysite.com/clientArea/?clientID=1234

那么所有内容需要重写为http://mysite.com/clientArea/XXX

例如,如果有人请求 http://clientA.mysite.com/example.css ,应重写为 http://mysite.com/clientArea/example.css

我一生都无法让这个工作正常。

我想我必须用两条规则来做到这一点。我认为我的第一条规则工作正常(页面看起来很糟糕,因为它无法获取 JS 文件或 CSS 文件以使其看起来正确)

这是我重写的第一条规则 http://clientA.mysite.comhttp://mysite.com/clientArea/?clientID=1234

<rule name="Rewrite Subdomain" stopProcessing="true">
     <match url="()" />
     <conditions>
         <add input="{HTTP_HOST}" pattern="^(?!www)clientA\.mysite\.com$" />
     </conditions>
     <action type="Rewrite" url="clientArea/?clientID=1234" appendQueryString="true" logRewrittenUrl="true" />
 </rule>

但是,我的第二条规则,我无法开始工作,因此任何有关此问题的帮助都会很好

<rule name="Rewrite Everything Else after subdomain">
    <match url="(.*)" />
    <conditions>
       <add input="{HTTP_HOST}" pattern="^(?!www)clientA\.mysite\.com$" />
    </conditions>
    <action type="Rewrite" url="{R:0}" />
 </rule>

请求诸如 http://clientA.mysite.com/example.js 返回 404 错误。

感谢您抽出时间, 凯尔

I'm having some trouble rewriting some things in IIS

Here is what I'm trying to achieve.

We have a bunch of clients that all need a subdomain. For example

http://clientA.mysite.com needs to be rewritten to http://mysite.com/clientArea/?clientID=1234

Then all content needs to be rewrriten to http://mysite.com/clientArea/XXX

so for example if someone requests http://clientA.mysite.com/example.css , that should be rewritten to http://mysite.com/clientArea/example.css

I cannot for the life of me get this working right.

I think I have to to do this in 2 rules. I think I have the first rule working kindof (page looks whack because it can't get the JS files or CSS files to make it look right)

Here is my first rule to rewrite http://clientA.mysite.com to http://mysite.com/clientArea/?clientID=1234

<rule name="Rewrite Subdomain" stopProcessing="true">
     <match url="()" />
     <conditions>
         <add input="{HTTP_HOST}" pattern="^(?!www)clientA\.mysite\.com$" />
     </conditions>
     <action type="Rewrite" url="clientArea/?clientID=1234" appendQueryString="true" logRewrittenUrl="true" />
 </rule>

My second rule, however, I cannot get to work, so any help with this would be great

<rule name="Rewrite Everything Else after subdomain">
    <match url="(.*)" />
    <conditions>
       <add input="{HTTP_HOST}" pattern="^(?!www)clientA\.mysite\.com$" />
    </conditions>
    <action type="Rewrite" url="{R:0}" />
 </rule>

Requesting things like http://clientA.mysite.com/example.js returns a 404 error.

Thanks for the time,
Kyle

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

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

发布评论

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

评论(2

还给你自由 2024-12-17 04:25:32

如果您的站点有专用的 IP 号码,则可以在 IIS 中将空的 http 绑定添加到您的站点(在 IIS 中右键单击您的站点 > 编辑绑定 > 添加)。然后在您的 DNS 配置中添加带有值:* 的 DNS“A”记录。因此,对您 IP 的每次调用都将由您的站点维护。

If you have dedicated IP number for your site, you can add empty http binding to your site in IIS (right click on your site in IIS > Edit bindings > Add). Then add DNS 'A' record with value: * in your DNS configuration. As a result, every call to your IP will be maintained by your site.

维持三分热 2024-12-17 04:25:32

您可以将入站和出站重写规则与应用程序请求路由模块结合使用。

入站规则将子文件夹代理到子域内容。出站规则检查响应并将响应中子域的所有实例替换为您的子文件夹路径。

You use a combination in inbound and outbound rewritting rules along with the Application Request Routing Module.

Inbound rule proxies the subfolder to the subdomain content. Outbound rule examines the response and replaces all instances of the subdomain in the response with your subfolder path.

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