I have a website in IIS that has several redirects which are working fine. Including one redirect that is a catch all which is using the ^ in the Pattern field.
I have recently been asked to create a redirect rule that will only run for mobile devices such as the iphone etc...
For example, my starting URL is www.myfirsturl.com this URL already redirects towww.mysecondurl.com/mycontent.htm using IIS7 URL Rewrite
We need to leave the above as is, but if www.myfirsturl.com is browsed from a mobile phone, I need a rule to redirect towww.mymobileurl.com/mobilecontent.htm
I followed the instructions in a blog post that uses the following rule:
<rule name="Mobile Rewrite" patternSyntax="ECMAScript" stopProcessing="true"><match url=".*" ignoreCase="true" negate="false" /><conditions logicalGrouping="MatchAny" trackAllCaptures="false"><add input="{HTTP_USER_AGENT}" pattern="midp|mobile|phone" /><add input="{HTTP_X-Device-User-Agent}" pattern="midp|mobile|phone" /><add input="{HTTP_X-OperaMini-Phone-UA}" pattern="midp|mobile|phone" /></conditions><action type="Redirect" url=http://www.mymobileurl.com/mobilecontent.htm appendQueryString="false" redirectType="Found" /></rule>
First of all, if I try to import this rule, the apply button never enables in the IIS GUI, so I decided to create the rule manually using the Add Rule(s) GUI. I also decided to create a test website to test this rule out.
If I set the rule up with (.*) in the Pattern field, I get a message on my phone that says "Safari cannot open the page because too many redirects occurred."
Next if I immediately switch the pattern field to the URL of my site (www.myfirsturl.com) and switch the Using field to "Exact match" it starts working (but only on my test site which has no other rules) however as soon as I clear the history/cache on my phone's web browser it no longer works.
On my production site it never works.
Can anyone please provide some help or guidance on how this is supposed to work.
Thank You so much.