[英]URL rewrite on IIS 8.0
I have installed URL rewrite module on the IIS 8.0 and configure rules 我已经在IIS 8.0上安装了URL重写模块并配置了规则
Below are the rules 以下是规则
<appcmd>
<CONFIG CONFIG.SECTION="system.webServer/rewrite/globalRules" path="MACHINE/WEBROOT/APPHOST" overrideMode="Inherit" locked="false">
<system.webServer-rewrite-globalRules>
<rule name="Mobile Redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^$" ignoreCase="true" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTP_USER_AGENT}" pattern="android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos" />
<add input="{HTTP_X-Device-User-Agent}" pattern="midp|mobile|phone" />
<add input="{HTTP_X-OperaMini-Phone-UA}" pattern="midp|mobile|phone" />
</conditions>
<serverVariables>
</serverVariables>
<action type="Redirect" url="/en-mobile" appendQueryString="false" />
</rule>
<rule name="Add HTTPS and WWW prefix to website.COM" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTP_HOST}" pattern="^website\.com" />
</conditions>
<serverVariables>
</serverVariables>
<action type="Redirect" url="https://www.website.com/{R:1}" appendQueryString="false" />
</rule>
<rule name="Add HTTPS to WWW.website.COM" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
</conditions>
<serverVariables>
</serverVariables>
<action type="Redirect" url="https://www.website.com/{R:1}" />
</rule>
</system.webServer-rewrite-globalRules>
</CONFIG>
</appcmd>
In above first rule Mobile redirect is done when user come from mobile browser. 在上述第一条规则中,当用户来自移动浏览器时,便完成了移动重定向。 I redirect to https://www.website.com/en-mobile
but when I do like this https://m.website.com/en-mobile
it gives error but when I browse manually it works very good. 我重定向到https://www.website.com/en-mobile
但是当我喜欢https://m.website.com/en-mobile
它会出现错误,但是当我手动浏览时,它的效果很好。 So how can I redirect to that url when people come from https://www.website.com to https://m.website.com/en-mobile 因此,当人们从https://www.website.com转到https://m.website.com/en-mobile时,如何重定向到该网址
I could solve this issue may be it will help to somebody so I am adding my solution over here. 我可以解决这个问题,也许对某人有帮助,所以我在这里添加解决方案。 I change Mobile Redirect rule action to 我将移动重定向规则操作更改为
<action type="Redirect" url="https://m.website.com/en-mobile" appendQueryString="true" redirectType="Found" />
Putting redirectType to found solves my issue. 把redirectType放到找到解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.