问号前为空时重定向
Redirect when it is empty before question mark
在 IIS 7.5 URL 重写模块下,我无法弄清楚如何在不干扰现有 URL 的情况下创建一个与查询标记前为空的 URL 匹配的掩码喜欢公司。com/invoice?id .
示例:
company.com?test 应该重定向到 company.com/en/
或
company.com/?test 应该重定向到 company.com/en/
我试过这条规则,但它干扰了 公司。com/invoice?id
<rule name="empty url">
<match url=".*" />
<conditions>
<add input="{REQUEST_URI}" pattern="/\?.*" />
</conditions>
<action type="Rewrite" url="/en/" appendQueryString="true" />
</rule>
谢谢!
这是我的解决方案:
<rule name="empty url">
<match url="^$" />
<conditions>
<add input="{QUERY_STRING}" pattern=".+" />
</conditions>
<action type="Redirect" url="/en/" appendQueryString="true" redirectType="Found" />
</rule>
在 IIS 7.5 URL 重写模块下,我无法弄清楚如何在不干扰现有 URL 的情况下创建一个与查询标记前为空的 URL 匹配的掩码喜欢公司。com/invoice?id .
示例:
company.com?test 应该重定向到 company.com/en/
或
company.com/?test 应该重定向到 company.com/en/
我试过这条规则,但它干扰了 公司。com/invoice?id
<rule name="empty url">
<match url=".*" />
<conditions>
<add input="{REQUEST_URI}" pattern="/\?.*" />
</conditions>
<action type="Rewrite" url="/en/" appendQueryString="true" />
</rule>
谢谢!
这是我的解决方案:
<rule name="empty url">
<match url="^$" />
<conditions>
<add input="{QUERY_STRING}" pattern=".+" />
</conditions>
<action type="Redirect" url="/en/" appendQueryString="true" redirectType="Found" />
</rule>