illestone Posted December 27, 2010 Share Posted December 27, 2010 I would like to be able to redirect any browser other than Firefox or IE to an alternate page. Could anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/222755-simple-browser-redirect/ Share on other sites More sharing options...
Psycho Posted December 27, 2010 Share Posted December 27, 2010 You can check the value of $_SERVER['HTTP_USER_AGENT'] and do a redirect based upon that value. However, that value can be spoofed by users if they really want to. So, it is not fool-proof. You would also have to determine how you will "decide" if the browser is IE or FF. Here are the contents of that variable using versions of IE7 and FF3 on my PC: - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB6.6; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; MS-RTC EA 2; MS-RTC LM - Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 GTB7.1 (.NET CLR 3.5.30729) I'm sure there are some best practices, but I would guess you could check if the value contains "MSIE" or "Firefox" Quote Link to comment https://forums.phpfreaks.com/topic/222755-simple-browser-redirect/#findComment-1151918 Share on other sites More sharing options...
illestone Posted December 27, 2010 Author Share Posted December 27, 2010 It dosen't have to be full proof, but more of a way to get traffic to where it should be for best viewing purposes. I am only a novice when it comes to PHP so anything helps. Quote Link to comment https://forums.phpfreaks.com/topic/222755-simple-browser-redirect/#findComment-1151922 Share on other sites More sharing options...
lastkarrde Posted December 28, 2010 Share Posted December 28, 2010 You could do it in PHP or Javascript. In PHP (as mjdamato said) there is the $_SERVER['HTTP_USER_AGENT'] . You could use substr to match the names of browsers (MSIE, Firefox). Then redirect using header(). In Javascript you could use Quirksmode's browser detection and change window.location accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/222755-simple-browser-redirect/#findComment-1152299 Share on other sites More sharing options...
Rifts Posted December 28, 2010 Share Posted December 28, 2010 why dont you just use different style sheets depending on which browser they have? Quote Link to comment https://forums.phpfreaks.com/topic/222755-simple-browser-redirect/#findComment-1152303 Share on other sites More sharing options...
Zurev Posted December 28, 2010 Share Posted December 28, 2010 Have a look at CSS conditionals, very useful. http://www.conditional-css.com/advanced Quote Link to comment https://forums.phpfreaks.com/topic/222755-simple-browser-redirect/#findComment-1152306 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.