简体   繁体   中英

url rewrite/redirect on iis7 redirect to mobile site

I have made all of my mobile folder/pages structure like the desktop version. I need to make sure all the requests from mobile devices will be re-directed to a mobile domain. what I would like to do is if a URL is opened from a mobile device like this: http://www.example.com/test/test.asp will be redirected to http://m.example.com/test/test.asp

this question might be asked before but I need to make sure it works.

Thanks very much

Take a look here:

http://forums.iis.net/t/1169853.aspx

This amends your web config to redirect -- not sure if it can be used on the page level, but it might be a good start.

I had the same problem and solve it.

<rule name="Mobile Redirect" stopProcessing="true">
      <match url="(.*)" ignoreCase="true" />
      <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
        <add input="{HTTP_USER_AGENT}" pattern="midp|mobil|phone" />
        <add input="{HTTP_X-Device-User-Agent}" pattern="midp|mobil|phone" />
        <add input="{HTTP_X-OperaMini-Phone-UA}" pattern="midp|mobil|phone" />
      </conditions>
      <action type="Redirect" url="http://m.yoursite.com/{R:1}" appendQueryString="true" />
    </rule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM