Under IIS 7.5 URL rewrite module, I cannot figure out how it is possible to create a mask that match an URL with empty before the query mark without interfering existing URL like company.com/invoice?id .
Example:
company.com?test should redirect to company.com/en/
OR
company.com/?test should redirect to company.com/en/
I tried this rule but it has interfered with company.com/invoice?id
<rule name="empty url">
<match url=".*" />
<conditions>
<add input="{REQUEST_URI}" pattern="/\?.*" />
</conditions>
<action type="Rewrite" url="/en/" appendQueryString="true" />
</rule>
Thank you!
Here my solution:
<rule name="empty url">
<match url="^$" />
<conditions>
<add input="{QUERY_STRING}" pattern=".+" />
</conditions>
<action type="Redirect" url="/en/" appendQueryString="true" redirectType="Found" />
</rule>