-1

Tell me how to redirect the user agent of certain browsers. I need users with safari and Samsung browser to go to another page.

Jek94
  • 7
  • 4
  • Does this answer your question? [IIS 7.5 URL Rewrite rule to handle request based on user agent](https://stackoverflow.com/questions/15904482/iis-7-5-url-rewrite-rule-to-handle-request-based-on-user-agent) – Lex Li Apr 03 '20 at 12:10
  • In this matter, redirection for all mobile devices, but I need for those who use safari and samsung browser. – Jek94 Apr 03 '20 at 13:19
  • "I need for those who use safari and samsung browser", then simply change to the pattern that matches those browsers. There are tons of database for such over the internet https://developers.whatismybrowser.com/useragents/explore/ – Lex Li Apr 03 '20 at 13:54
  • I can’t understand how to write a rule in the web config. – Jek94 Apr 04 '20 at 07:09

1 Answers1

0

Please install URL rewrite module first.

https://www.iis.net/downloads/microsoft/url-rewrite.

Since there is no characteristic for specific OS platform, you have to use http_user_agent variable to filter the request.

This is just a sample to redirect safari 12.1

<rule name="redirect agent" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_USER_AGENT}" pattern="Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Mobile/15E148 Safari/604.1" />
                </conditions>
                <action type="Redirect" url="http://newsite.domain.com/" />
            </rule>

You could create a rewritemap list to handle different kinds of web browser.

https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module

Jokies Ding
  • 3,374
  • 1
  • 5
  • 10