在ASP.NET中使用IIS不能对主机头进行URL重写 [英] URL Rewrite for Host Header is not working using IIS in asp.net

查看:65
本文介绍了在ASP.NET中使用IIS不能对主机头进行URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想重定向任何恶意链接或用户以重定向到其他域.相反,它应该重定向到我提到的域.为此,我在下面编写了使用IIS服务器的重写URL规则

I do not want to redirect any malicious link or user to redirect to other domain. Instead it should redirect to the domain which I mentioned. So for that, I have written below Rewrite URL rule by using IIS server

<rewrite>
  <rules>
    <clear />
    <rule name="Redirect to https" stopProcessing="true">
      <match url=".*" />
      <conditions>
                    <add input="{HTTPS}" pattern="off" />
                    <add input="{HTTP_HOST}" matchType="Pattern" pattern="^([a-zA-Z0-9-_]+.)https://nvmbd1bkh150v02.rjil.ril.com$" ignoreCase="true" negate="true" />
      </conditions>
      <action type="Redirect" url="https://nvmbd1bkh150v02.rjil.ril.com/FiberInventoryPortal" redirectType="Permanent" appendQueryString="false" />
    </rule>

  </rules>
</rewrite>

但是这里发生的是,我所有的应用程序CSS都被打乱了.请建议在这种情况下我该怎么办.

But what happening here is, all my application CSS gets disturbed. Please suggest what should I do in this case.

推荐答案

不确定恶意"链接的含义,但我猜测您希望访问者仅使用该特定主机名.并且每个URL都应始终以/FiberInventoryPortal/开头.

Not sure what you mean with "malicious" links but my guess is that you want visitors to use just that specific host name. And also that every URL should always start with /FiberInventoryPortal/.

所以这可能就是您想要的:

So possibly this is what you want:

<rewrite>
    <rules>
        <clear />
        <rule name="Force HTTPS" stopProcessing="true">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAll">
                <add input="{HTTPS}" negate="true" pattern="^ON$" />
                <add input="{HTTP_HOST}" negate="true" pattern="^nvmbd1bkh150v02\.rjil\.ril\.com$" />
            </conditions>
            <action type="Redirect" url="https://nvmbd1bkh150v02.rjil.ril.com{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
        </rule>
        <rule name="Redirect to FiberInventoryPortal" stopProcessing="true">
            <match url=".*" />
            <conditions>
                <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/FiberInventoryPortal/" ignoreCase="true" negate="true" />
            </conditions>
            <action type="Redirect" url="https://nvmbd1bkh150v02.rjil.ril.com/FiberInventoryPortal/{R:0}" redirectType="Permanent" appendQueryString="false" />
        </rule>
    </rules>
</rewrite>

这篇关于在ASP.NET中使用IIS不能对主机头进行URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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