Monj87 Posted August 15, 2011 Share Posted August 15, 2011 Trying to set a condition in my header a few questions: This code is close but gives me an error code and doesn't redirect. 1) Can anyone figure out how to make this work so that if user is in IE6 the url will redirect to the second URL? 2) I would put this in my header right? I can't figure out why this isn't working. <?php $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; function str_present($str,$substr) { $pos = strpos($str,$substr); if($pos === false) { return false; } else { return true; } } if (str_present($HTTP_USER_AGENT, "IE6")) { header('location: url1'); }else{ header('location: url2'); } ?> Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted August 15, 2011 Share Posted August 15, 2011 it's always a nice thing if you let others know what exact error you get. Besides that if you are only targeting ie6, you might want to add a meta redirect with conditional comments like so: <!--[if IE 6]> <meta http-equiv="refresh" content="0; url=http://example.com/"> <![endif]--> place it in the header Quote Link to comment Share on other sites More sharing options...
Monj87 Posted August 24, 2011 Author Share Posted August 24, 2011 THIS IS AWESOME. Ive been searching everywhere though and how the heck would i replace "IE 6" with to do this with FireFox 2? Could you point me in the right direction to find that out or let me know? THANKS!!! IT WORKED AWESOME Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted August 24, 2011 Share Posted August 24, 2011 type in google conditional comments first link or try: http://www.quirksmode.org/css/condcom.html Not sure what you want to use this for though. I only use it to back up ie 7 and 6. If you want a more complete thing use this: http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/ good luck! eidt: and mark it solved ones your done Quote Link to comment Share on other sites More sharing options...
Monj87 Posted August 24, 2011 Author Share Posted August 24, 2011 Thanks a lot but those are for IE I need firefox2 any pointers? Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted August 24, 2011 Share Posted August 24, 2011 type in google conditional comments first link or try: http://www.quirksmode.org/css/condcom.html Not sure what you want to use this for though. I only use it to back up ie 7 and 6. If you want a more complete thing use this: http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/ good luck! eidt: and mark it solved ones your done did you read this?? Quote Link to comment Share on other sites More sharing options...
Monj87 Posted August 24, 2011 Author Share Posted August 24, 2011 Yes i read it. What i found in there was that FF is hard to create conditionals with. I really don't have time to do research looking a quick answer =) (thank you in advance) Can anyone give me the answer? HOW do i replace "IE6" with Fire Fox 2 in this code. so that i can put it into a prefixed conditional statement like this. <!--[if IE 6]> <meta http-equiv="refresh" content="0; url=http://example.com/"> <![endif]--> Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted August 24, 2011 Share Posted August 24, 2011 are you serious???? If you want a more complete thing use this: http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/ good luck! did you click that? Are you seriously expecting that people here copy paste that stuff for you? and post it here so you don't have to do the effort? Quote Link to comment 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.