Skip to content
Advertisement

Redirecting non Safari mobile browser?

I am looking for assistance with coding to detect and redirect a iOS user on any browser other than Safari. I was able to accomplish this via .htaccess, but for iPhone & iPad redirect only, via this:

RewriteCond %{HTTP_USER_AGENT} iphone|ipad [NC]
RewriteRule ^$ /ios.php

But, I only intend it for non-Safari iOS browsers on iPhone and iPad. Open to other methods than htaccess. Our WebRTC script only works on Safari.

Advertisement

Answer

If you have not found a solution, you can test this:

RewriteEngine on

RewriteCond %{HTTP_USER_AGENT} iphone|ipad [NC]
RewriteCond %{HTTP_USER_AGENT} Safari [NC]
RewriteCond %{HTTP_USER_AGENT} !(CriOS|OPiOS) [NC]
RewriteRule ^$ /safari-with-webrtc.php [L]

RewriteRule ^$ /ios-without-webrtc.php [L]

First we check if we are using iphone|ipad, the second directive detects safari. But chrome presents also with name safari, we exclude CriOS for Google Chrome and OPiOS for Opera, so we have True safari, we run /safari-with-webrtc.php.

Otherwise, we are not on iPhone|iPad with Safari, we run /ios-without-webrtc.php.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement