[英]URL Rewrite on IIS always fail when change the pattern
I'm trying to work in a rewrite problem, but its my first time and I guess I'm doing something very wrong. 我正在尝试解决重写问题,但这是我的第一次,我想我做错了什么。
A few users of our portal, try to navigate typing https://www.dudalina.proveagora.com instead the right one https://dudalina.proveagora.com . 我们门户网站的一些用户尝试导航输入https://www.dudalina.proveagora.com而不是正确的https://dudalina.proveagora.com 。 We have the SSL only for *.proveagora.com, so I started to try a redirect on the users who type the wrong url. 我们仅针对* .proveagora.com提供SSL,因此我开始尝试对输入错误网址的用户进行重定向。 Here, the print of rewrite working great: 在这里,重写的效果很好:
but, some users type https:// and some users type http://. 但是,某些用户键入https://,而某些用户键入http://。 By this way, I've tried to change the pattern. 通过这种方式,我尝试更改模式。
I dont know why, but using the second pattern, the url https://www.dudalina.proveagora.com doesnt redirect anymore. 我不知道为什么,但是使用第二种模式,URL https://www.dudalina.proveagora.com不再重定向。
Just to explain a little more, the dudalina part is dynamic too. 为了进一步说明,dudalina部分也是动态的。 Dudalina is the store name, and it will change accordingly with store. 达达利纳(Dudalina)是商店名称,它将随商店而改变。 So, we can have latter something like http://bestbuy.proveagora.com or anything else and this patterns much works with all the options. 因此,我们可以使用诸如http://bestbuy.proveagora.com之类的后者或其他任何东西,并且这种模式对所有选项都有效。
I know, the user cant type www.bestbuy.proveagora.com but they do, and we need to make it works! 我知道,用户不能输入www.bestbuy.proveagora.com,但他们可以输入,我们需要使其有效! :( :(
Any help? 有什么帮助吗?
EDIT 编辑
xml Web.Config xml Web.Config
<rewrite>
<rules>
<rule name="RemoveWWWPrefix" stopProcessing="true">
<match url="(.*)" negate="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="^(https\:\/\/|https\:\/\/)?([a-zA-Z]+\.)?(proveagora\.com){1}(\/.*)?$" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" url="http://dudalina.proveagora.com" appendQueryString="false" />
</rule>
</rules>
</rewrite>
Here you go: 干得好:
<rule name="RemoveWWWPrefix" stopProcessing="true">
<match url="(.*)" negate="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="^(.+\.)proveagora\.com$" />
<add input="{HTTP_HOST}" pattern="^dudalina\.proveagora\.com$" negate="true" />
<add input="{HTTPS}" pattern="^ON$" />
</conditions>
<action type="Redirect" url="https://dudalina.proveagora.com" appendQueryString="false" />
</rule>
What it will check is that the protocol used is HTTPS
and that the subdomain of proveagora.com
is present and different from dudalina
. 它要检查的是所使用的协议是HTTPS
并且proveagora.com
的子域存在并且与dudalina
不同。
If that's the case, it redirects to https://dudalina.proveagora.com
如果是这样,它将重定向到https://dudalina.proveagora.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.