...

View Full Version : Mobile browser detection and redirection



nicky
10-15-2009, 03:30 AM
I'm trying to expand my website's compatibility to mobile devices. My website is www.inthedesigns.net, and I would like it to detect mobile browsers and redirect to http://m.inthedesigns.net.

I know javascript is out of the question since the majority of mobile devices either don't support it or it's turned off by default.

Is there a simple way of doing this, like through PHP or my .htaccess file?

Much thanks!

oesxyl
10-15-2009, 03:39 AM
I'm trying to expand my website's compatibility to mobile devices. My website is www.inthedesigns.net, and I would like it to detect mobile browsers and redirect to http://m.inthedesigns.net.

I know javascript is out of the question since the majority of mobile devices either don't support it or it's turned off by default.

Is there a simple way of doing this, like through PHP or my .htaccess file?

Much thanks!

http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide_advanced.html#browser-dependent-content

I just find this:
http://detectmobilebrowsers.mobi/
best regards

nicky
10-20-2009, 02:48 AM
I couldn't implement the PHP coding in my header.php file. It kept saying there was an error.

oracleguy
10-20-2009, 09:46 PM
What error?

There is also the media attribute you can use on the link tag when you bring in stylesheets so you can have a different one for mobile browsers. However obeying that is up to the browser, I believe the iPhone browser uses the screen media type and not the mobile one (as an example).

oesxyl
10-21-2009, 03:37 AM
I couldn't implement the PHP coding in my header.php file. It kept saying there was an error.


What error?

There is also the media attribute you can use on the link tag when you bring in stylesheets so you can have a different one for mobile browsers. However obeying that is up to the browser, I believe the iPhone browser uses the screen media type and not the mobile one (as an example).
a guess:


Warning: Cannot modify header information - headers already sent by (output started at...
if this is the case, you can't echo or print anything before the header line.

best regards

davemanjra
11-24-2009, 12:10 AM
@nicky,

There are a few web services set up already which do this. we use handsetdetection.com

In some cases, rather than just detecting whether the person browsing is mobile or not, we customise our clients sites to be optimised to the screen size of the actual device.

ghost2012
07-02-2010, 01:50 PM
I use this as index.php and redirect it according to the device.


<?php
$mobile = $_SERVER['HTTP_USER_AGENT'];
$bberry = "BlackBerry";
$blackberry = 'http://blackberry.yoursite.com/';
$main = "default.php";
if ((strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry')) !== false)
{
header("location: $blackberry");
}
else
{
header("location: $main");
}
?>

This is the code I use in a PHP script that works perfectly for me.

raymonddenis
12-17-2010, 10:09 PM
You could also use a rewrite rule in .htaccess that would be something similar such as:


RewriteCond %{HTTP_USER_AGENT} (OneMobileUserAgent|AnotherMobileUserAgent|...)
RewriteRule (.*) $1?mobile=1 [L]

Just need to paste your mobileuseragent list in the condition and voila.


______________________
Assurance auto (http://www.axa.ca/assurance-auto)

zinedinezidane
12-18-2010, 06:12 AM
Do any of you know how to receive messages using SMS gateway or Ozeki Message server?

I am able to send SMS but not receive.

snaker190
01-03-2011, 08:31 PM
Do any of you know how to receive messages using SMS gateway or Ozeki Message server?

I am able to send SMS but not receive.

Ya i am having the same problem can enny one help



______________________
Naruto Shippuden (http://narutosick.com/)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum